在 AngularJS 中输入类型编号

Input type number in AngularJS

我在AngularJS中有一个输入类型编号如下...

<input type="number"></input>

我想实现以下目标:

谁能告诉我如何动态实现这个?

<input type="number" ng-change="amountChanged()" ng-style="myStyle.color" ng-model="amount"/>

$scope.myStyle= {};
$scope.amountChanged = function () {

   if($scope.amount < 0)
   {
      $scope.myStyle.color= {"color":"green"};
   }
   else
   {
      $scope.myStyle.color= {"color":"blue"};
   }

}

希望对您有所帮助。

  <input type="number" ng-model="number">
    <label ng-show="number > 0" style="color:green;">You are Correct</label>
    <label ng-show="number < 0" style="color:red;">Your number is negative</label>

你可以做到这一点。

HTML

<input type="number" ng-class="{negative: amount < 0, positive: amount > 0}" ng-model="amount"/>

CSS

.negative {
   color: red;
}
.positive {
    color: green;
}