angular中的module

来源:互联网 发布:sai中文版官方下载mac 编辑:程序博客网 时间:2024/06/16 05:55

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(){    })//servicesangular.module('services',[])    .value('greet',{        //code    })//filtersangular.module('filters',[]);//derectivesangular.module('derectives',[]);
原创粉丝点击