ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、视频、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
> ng-app > ng-controller (viewmodel) ~~~ <body ng-app="example" ng-controller="con1"> {{data}} ~~~ ~~~ var m = module('example',[]); m.controller("con1",["$scope",function($scope){ $scope.data = 1; }]) ~~~ ### 双向数据绑定 > 1.$scope和view之间的绑定 2.html更新范围是所属于的controller ~~~ <body ng-app="example" ng-controller="con1"> <h2 ng-bind="name"></h2> <input type="text" ng-model="name"> </body> ~~~ ~~~ var m = angular.module('example',[]); m.controller('con1',['$scope',function ($scope) { $scope.name = 'iooni'; }]); ~~~ ![双向数据绑定](https://box.kancloud.cn/7bcc8c22aee76312905f172f397a89fb_409x164.png)