AngularJS - 插件,module注入

Index.html

<body>
    <div ng-app="myApp">
        <div ng-controller="firstController">
           {{name}}
        </div>
        <div ng-controller="secondController">
            {{name}}
        </div>
        <div ng-controller="thirdController">
            {{name}}
        </div>
    </div>
    <script type="text/javascript">
        var app = angular.module("myApp", ['myApp2']);

        app.controller('firstController', ['$scope', function ($scope) {
            $scope.name = "张三";

        }]);
    </script>
</body>

Modules.js

//张三,李四,王五全部输出
var app2 = angular.module("myApp2", []);

app2.controller('secondController', ['$scope', function ($scope) {
    $scope.name = "李四";

}]);

app2.controller('thirdController', ['$scope', function ($scope) {
    $scope.name = "王五";
}]);

 

posted @ 2016-04-04 22:51  MrMrCash  阅读(352)  评论(0编辑  收藏  举报