Ng 模型选项不适用于 $scope 变量
Ng Model Options is not working from $scope variable
我的 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>
提前致谢
这里有几件事不太正确。首先,您没有正确声明 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>
我的 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>
提前致谢
这里有几件事不太正确。首先,您没有正确声明 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>