angularjs controller的两种写法及区别
来源:互联网 发布:xp扫描仪软件 编辑:程序博客网 时间:2024/04/29 17:04
在Angular中,Directive、Service、Filter、Controller都是以工厂方法的方式给出,而工厂方法的参数名对应着该工厂方法依赖的Service。如:
app.controller('wolrdCtrl', function($scope, $http){ // ...});
在上述的function
执行之前,Angular Injector会生成一个$scope
的实例和$http
的实例,并传入该方法。 如果你希望对JS进行压缩处理,那么参数名就可能发生变化,Angular Injector将不能够正确地注入依赖的Service。于是有另外一种写法:
app.controller('wolrdCtrl', ['$scope', '$http', function($scope, $http){ // ...}]);
以字符串数组的形式来声明依赖项,因为字符串常量不会被压缩。
0 0
- angularjs controller的两种写法及区别
- 转 angularjs controller的两种写法
- Controller的两种写法
- angularjs 的controller的三种写法
- angularjs-controller的另外一种写法
- 两种写法的区别
- angularJs-论模块化写法的两种方式
- 对话框的OnPaint函数的两种写法的区别
- Android 两种隐藏系统状态栏的写法的区别
- Controller的写法
- angularJS+requireJS实现controller及directive的按需加载
- angularJS+requireJS实现controller及directive的按需加载
- angularJS+requireJS实现controller及directive的按需加载
- angularJS+requireJS实现controller及directive的按需加载
- 两种sql写法 有区别吗
- Timer 误区,及两种正确写法
- 状态机的两种写法
- 状态机的两种写法
- sar 监控系统状态
- poj 1159 palindrome-----动态规划
- 查看linux系统版本命令
- 【AngularJS】刷新页面时,短暂出现未渲染的代码
- Android的.9图片
- angularjs controller的两种写法及区别
- 更改主机名
- _beginthreadex&&CreateThread
- 在mysql中设置utf8_bin下 like搜索 不想区分大小写
- 防火墙
- 面向对象3
- 数组指针,指针数组,函数指针,指针函数
- Linux中粘滞位
- Spring Data MongoDB 基础查询