33.AngularJS 应用 angular.module定义应用 angular.controller控制应用

转自:https://www.cnblogs.com/best/tag/Angular/

AngularJS 模块(Module) 定义了 AngularJS 应用。

AngularJS 控制器(Controller) 用于控制 AngularJS 应用。

ng-app指令定义了应用, ng-controller 定义了控制器。

 1 <div ng-app="myApp" ng-controller="myCtrl">
 2  
 3 名: <input type="text" ng-model="firstName"><br>
 4 姓: <input type="text" ng-model="lastName"><br>
 5 <br>
 6 姓名: {{firstName + " " + lastName}}
 7  
 8 </div>
 9  
10 <script>
11 var app = angular.module('myApp', []);
12 app.controller('myCtrl', function($scope) {
13     $scope.firstName= "John";
14     $scope.lastName= "Doe";
15 });
16 </script>
原文地址:https://www.cnblogs.com/sharpest/p/8175970.html