1、关于ng-app、angular.module和ng-controller。
<html ng-app="myApp"> ... ... <div ng-controller="Aaa"> <p>{{name}}</p> </div> <div ng-controller="Bbb"> <p>{{name}}</p> </div> ----JS--- var m1 = angular.module('myApp',[]); m1.controller('Aaa',['$scope',function($scope){ $scope.name = 'hello'; }]); m1.controller('Bbb',['$scope',function($scope){ $scope.name = 'hi'; }]);
1