一,声名式注入

1:app.js:

var myApp = angular.module("myApp",["ngRoute"]);

2:controller.js:

myApp.controller("indexCtrl",['$scope',function($scope){              //如果想用混淆,必须使用中括号中声名注入参数

}])

3:config.js:

myApp.config(function($routeProvider, $locationProvider) {
    $routeProvider
    .when('/a', {
        templateUrl: 'web/templates/a.html',
        controller: 'aController'
    })
    .when('/b', {
        templateUrl: 'web/templates/b.html',
        controller: 'bController',
    .otherwise({
        redirectTo: '/a'
    });
});

二,直接注入

1:app.js

angular.moudle("myApp",[

  'ngRoute',

  'myApp.config',

'myApp.controllers'

]);

2:controllers.js

angular.module("myApp.controllers",[])  //如果想用混淆,必须使用中括号中声名注入参数

.controller("myCtrl",function($scope){

})

.controller("otherCtrl",function($scope){

})

3:config.js

angular.module("myApp.config",[])

.config(function($routeProvider, $locationProvider) {
    $routeProvider
    .when('/a', {
        templateUrl: 'web/templates/a.html',
        controller: 'aController'
    })
    .when('/b', {
        templateUrl: 'web/templates/b.html',
        controller: 'bController',
    .otherwise({
        redirectTo: '/a'
    });
});

最新文章

  1. bash shell + python简单教程,让你的mac/linux终端灰起来~
  2. 转mysql复制主从集群搭建
  3. UVa 10883 (组合数 对数) Supermean
  4. TCP带外数据读写
  5. 知识库总结mysql常用cmd命令
  6. SQL数据库知识二(Day 25)
  7. android 应用程序框架
  8. OC与Swift桥接问题
  9. AngularJS进阶(十八)在AngularJS应用中集成科大讯飞语音输入功能
  10. 四面美团,收割 offer
  11. Gradle 教程
  12. C++设计模式(第一周)
  13. iOS 证书 设置指南
  14. gVim中重新载入当前文件
  15. fiddler的介绍
  16. linux 下多版本gcc 共存问题
  17. HMAC结合“挑战/响应”保障数据传输安全
  18. java实现快速排序算法
  19. redis1
  20. HDU 1160(两个值的LIS,需dfs输出路径)

热门文章

  1. Webdriver测试脚本2(控制浏览器)
  2. java中使用Protobuf的实例(Demo)
  3. 安装eclipse插件,很慢终于找到了解决的方法
  4. Big String(poj 2887)
  5. [网络流24题] 骑士共存(cogs 746)
  6. linux 命令练习 2018-08-27
  7. nyoj_758_分苹果
  8. Cardboard虚拟现实开发初步(二)
  9. 1064 - You have an error in your SQL syntax问题解决
  10. javaWeb_使用标签库简化jsp