Ng模型选项不能使用$scope变量

时间:2021-12-12 23:46:59

My ng-model should update Onblur: Immediately Typing: after 0.5 sec. Why is this not happening?

我的ng-model应该更新Onblur:立即输入:0.5秒后。为什么不会发生这种情况?

app = angular.module("dailySheetApp", []);
app.controller("dailySheetCtrl", function($scope) {

  $scope.inputBounce= { "updateOn":"default blur","debounce":{"default":500,"blur":0} };


});
<html ng-app="dailySheetApp">
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
  <body ng-controller="dailySheetCtrl">
    <input type="text" ng-model="data" ng-model="inputBounce">
  {{data}}
  </body>
</html>

Thankyou in advance

谢谢提前

1 个解决方案

#1


3  

A couple of things are not quite correct here. Firstly, you did not declare ng-model-options correctly. Observe the markup change. Secondly, ngModelOptions is not available in 1.2.x. The updated example is using 1.3.0

这里有两件事不太正确。首先,您没有正确地声明ng-model-options。观察标记变化。第二,ngModelOptions在1.2.x中不可用。更新后的示例使用1.3.0

app = angular.module("dailySheetApp", []);
app.controller("dailySheetCtrl", function($scope) {
  $scope.inputBounce= { "updateOn":"default blur","debounce":{"default":500,"blur":0} };
});
<html ng-app="dailySheetApp">
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0/angular.min.js"></script>
  <body ng-controller="dailySheetCtrl">
    <input type="text" ng-model="data" ng-model-options="inputBounce">
    {{data}}
  </body>
</html>

#1


3  

A couple of things are not quite correct here. Firstly, you did not declare ng-model-options correctly. Observe the markup change. Secondly, ngModelOptions is not available in 1.2.x. The updated example is using 1.3.0

这里有两件事不太正确。首先,您没有正确地声明ng-model-options。观察标记变化。第二,ngModelOptions在1.2.x中不可用。更新后的示例使用1.3.0

app = angular.module("dailySheetApp", []);
app.controller("dailySheetCtrl", function($scope) {
  $scope.inputBounce= { "updateOn":"default blur","debounce":{"default":500,"blur":0} };
});
<html ng-app="dailySheetApp">
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0/angular.min.js"></script>
  <body ng-controller="dailySheetCtrl">
    <input type="text" ng-model="data" ng-model-options="inputBounce">
    {{data}}
  </body>
</html>