Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/404.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 文本框长整数值,以angualrjs显示为指数类型_Javascript_Html_Angularjs - Fatal编程技术网

Javascript 文本框长整数值,以angualrjs显示为指数类型

Javascript 文本框长整数值,以angualrjs显示为指数类型,javascript,html,angularjs,Javascript,Html,Angularjs,我有文本框,值由模型指定 <input class="form-control" type='text' ng-focus='getFocusEl($event)' ng-change='profileNameValidate(profileData.profileName)' ng-model='profileData.profileName' maxlength="64"> 在文本框中显示时1.2234245345688787e+63 我需要在文本框中显示全长整数 如何做到这一

我有文本框,值由模型指定

<input class="form-control" type='text' ng-focus='getFocusEl($event)' ng-change='profileNameValidate(profileData.profileName)' ng-model='profileData.profileName' maxlength="64">
在文本框中显示时
1.2234245345688787e+63

我需要在文本框中显示全长整数


如何做到这一点?

最好的方法是在将值设置到文本框之前对其进行字符串化。此外,如果使用angular>=1.3,则可以利用getter setter函数

<input class="form-control" type='text' ng-focus='getFocusEl($event)' ng-change='profileNameValidate(profileData.profileName)' ng-model='profileData.profileName.getString' maxlength="64"
ng-model-options=" {getterSetter: true }">

有关更多信息,请参阅绑定getter/setter一节。最好的方法是在将值设置到文本框之前对其进行字符串化。此外,如果使用angular>=1.3,则可以利用getter setter函数

<input class="form-control" type='text' ng-focus='getFocusEl($event)' ng-change='profileNameValidate(profileData.profileName)' ng-model='profileData.profileName.getString' maxlength="64"
ng-model-options=" {getterSetter: true }">

有关更多信息,请参阅绑定getter/setter一节

为什么要这样做?从可用性的角度来看,这会很困难,对吗?如果服务器的值是整数格式的,那么您可以将其转换为字符串。服务器仅以字符串形式发送使用字符串(passyournumber)我也尝试过使用字符串()。对于textbox,这种行为是很常见的。显示完整长度值的剩余位置为什么要这样做?从可用性的角度来看,这会很困难,对吗?如果服务器的值是整数格式的,那么您可以将其转换为字符串。服务器仅以字符串形式发送使用字符串(passyournumber)我也尝试过使用字符串()。对于textbox,这种行为是很常见的。剩下的地方它显示了完整的长度值为什么我们需要这样做?。行为是什么?这种方式,每当ng模型更改时,它都会调用该ng模型的getter方法,您将完全控制要返回的值。您可以在该函数中截断/字符串化/更新它。如果toString不起作用,请尝试在结尾追加一个空格。为什么我们需要这样做?。行为是什么这种方式,每当ng模型更改时,它将调用该ng模型的getter方法,并且您将完全控制要返回的值。您可以在该函数中截断/stringify/update等。此外,如果toString不起作用,请尝试在末尾追加空格。
$scope.profileData.profileName.getString: function (value) {
  if (angular.isDefined(value)) {
    $scope.profileData.profileName = value;
  } else {        
    return $scope.profileData.profileName.toString();
  );
 }
}