textbox长整数值,在angualrjs中显示为指数类型

时间:2016-09-14 07:08:04

标签: javascript html angularjs

我有文本框,值由模型分配

<input class="form-control" type='text' ng-focus='getFocusEl($event)' ng-change='profileNameValidate(profileData.profileName)' ng-model='profileData.profileName' maxlength="64">

如果该文本框值来自api为

1223424534568878687676786786786876786786786786876767867868768768

在文本框1.2234245345688787e+63

中显示

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

怎么做?

1 个答案:

答案 0 :(得分:0)

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

$scope.profileData.profileName.getString: function (value) {
  if (angular.isDefined(value)) {
    $scope.profileData.profileName = value;
  } else {        
    return $scope.profileData.profileName.toString();
  );
 }
}

然后在你的控制器中

showDiag

有关详情,请参阅Binding getter / setter ng-model

部分
相关问题