1、描述

在angular中,module是其他专用对象以及服务的载体。所有的服务、指令、控制器等等都依赖于相对应的那个module。module之间存在着依赖注入的关系。

2、最简单的module使用

angular.module("app",[])
    .controller('ctrl',["$scope",function($scope){ 
        $scope.name = 'mapbar_front';
    }])

3、大型应用中的module使用

应该把module分为这么几个模块:
1、服务模块
2、指令模块
3、filter模块
4、一个应用的模块,应该依赖于上面三个模块。

angular.module('app',['services','filters', 'derectives'])
    .controller('myctrl',function($scope){
        //code
    })
    .run(function(){

    })

//services
angular.module('services',[])
    .value('greet',{
        //code
    })
//filters
angular.module('filters',[]);
//derectives
angular.module('derectives',[]);
Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐