首页 > Web开发 > 详细

AngularJS - 插件,module注入

时间:2016-04-05 00:15:34      阅读:324      评论:0      收藏:0      [点我收藏+]

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 = "王五";
}]);

 

AngularJS - 插件,module注入

原文:http://www.cnblogs.com/MarchThree/p/5353254.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!