AngularJS控制器
<body ng-app> <div ng-controller="myCtrl"> <h1>{{say}}</h1> <h1>{{name()}}</h1> </div> <script> function myCtrl($scope) { $scope.say = 'hi,大家好'; $scope.name = function () { return $scope.say + ',我叫Handsome!'; } } </script> </body>
<body ng-app> <div ng-controller="myCtrl"> <h1>{{say}}</h1> <h1>{{name()}}</h1> </div> <script> function myCtrl($scope) { $scope.say = 'hi,大家好'; $scope.name = function () { return $scope.say + ',我叫Handsome!'; } } </script> </body>