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