Angularjs模块依赖

来源:互联网 发布:淘宝网天猫手机外壳 编辑:程序博客网 时间:2024/06/01 07:11
angular.module('app', [
'ui.router',
'ui.bootstrap',
'infomonitor',//自定义module 应用程序app依赖此模块 在该模块下已经定义好路由配置 在首页将模块依赖的js文件导入即可
'hotpoint',
'analysis',
'infoalarm',
'search',
'materialmanage',
'knowledgepool',
'systemmanage',
]);

<script> angular.module('app',['ngRoute']) .config(['$routeProvider', function($routeProvider){ $routeProvider .when('/',{template:'这是首页页面'}) .when('/computers',{template:'这是电脑分类页面'}) .when('/printers',{template:'这是打印机页面'}) .otherwise({redirectTo:'/'}); }]);
</script>


anjularjs中的模块和控制器是写在js文件中的
首先定义一个主应用程序,主应用模块依赖模块定义在js文件中,使用模块来声明应用应该如何启动
一般现在我使用的是人家已经封装好的第三方模块,例如'ngRouter','ui.router'等等
也可以自己写模块,自己定义好应用程序如何启动。使用anjular.module('自定义modul名称',[依赖模块若不依赖则空])
anjular.module('modulename',[]).config(){}用于配置路由规则
可分解为:
anjular.module('自定义modul名称',[依赖模块若不依赖则空])
module.config(){}配置路由规则