AngularJS的数据双向绑定是怎么实现的

2025-04-04 04:48:39
推荐回答(1个)
回答1:

双向数据绑定是AngularJS最强大也是最有特色的功能之一,如果这个不清除的话,那还得重新看看API,重新认识AngularJS,给你举个例子吧:
html:



{{greeting}}




js:
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.name = "Runoob";
$scope.sayHello = function() {
$scope.greeting = 'Hello ' + $scope.name + '!';
};
});