angularJS学习之路(十三)---ng-change

来源:互联网 发布:windows优化大师教程 编辑:程序博客网 时间:2024/04/29 22:12

在表单输入发生变化时调用:


<!DOCTYPE html><html ng-app="myApp"><head><meta charset="utf-8"><title></title></head><body><div ng-controller="EquationController"><input type="text" ng-model="equation.x" ng-change="change()" /><code>{{ equation.output }}</code></div><script type="text/javascript" src="../js/angular.min.js"></script><script>var app = angular.module('myApp', []);app.controller('EquationController', function($scope) {$scope.equation = {};$scope.change = function() {$scope.equation.output = Number($scope.equation.x) + 2;};});</script></body></html>


0 0
原创粉丝点击