Hide Value in input when it's zero in angular Js

后端 未结 7 2064
北恋
北恋 2020-12-19 15:56

I have an angular object item.add_value = 0 bind into the



        
相关标签:
7条回答
  • 2020-12-19 16:44

    var app = angular.module('app', []);
    
    app.controller('firstCtrl', function($scope) {
    
      $scope.item = {
        add_value: 0
      };
    
      $scope.$watch('item.add_value', function() {
        if ($scope.item.add_value === 0) {
          $scope.item.add_value = "";
    
        }
    
      });
    });
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
    
    <div ng-app="app">
      <div ng-controller="firstCtrl">
        <input type="number" ng-model="item.add_value" ng-change="sumUp(item)" min="0" max="10000000000" />
    
    
      </div>
    </div>

    0 讨论(0)
提交回复
热议问题