替代语法angular.module.controller [英] Alternative syntax for angular.module.controller
本文介绍了替代语法angular.module.controller的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有指令和应用程序,它是模块控制器模块。
angular.module('ValidationWidgets',[])
.directive('validationfield',函数(){
....
});
angular.module('我的页面',['ValidationWidgets'])
.controller('MyFirstController',函数($范围){ ....
});
有一些pretty语法来声明在应用模块多个控制器,因为 .controller('MyFirstController',函数($范围内){
不妙?
我想写类似:
VAR MYPAGE = angular.module('我的页面',['ValidationWidgets']);myPage.controllers.MyFirstController =功能($范围){
...
}
解决方案
VAR应用= angular.module(对myApp,[]);
app.controller(我的控制器功能(){});
或
VAR应用= angular.module(对myApp,[]);
变种控制器= {};
controller.myController =函数(){};
app.controller(控制器);
看看这个视频 http://egghead.io/video / angularjs思维,不同的-有关组织/
整个系列是惊人的是诚实的。
I have module with directive and application which is module with controllers.
angular.module('ValidationWidgets', [])
.directive('validationfield', function () {
....
});
angular.module('MyPage', ['ValidationWidgets'])
.controller('MyFirstController', function ($scope) {
....
});
Is there some pretty syntax to declare many controllers in app module, because .controller('MyFirstController', function ($scope) {
looks bad?
I want to write something like:
var myPage = angular.module('MyPage', ['ValidationWidgets']);
myPage.controllers.MyFirstController = function($scope) {
...
}
解决方案
var app = angular.module("myApp", []);
app.controller("my controller", function(){});
or
var app = angular.module("myApp", []);
var controllers = {};
controller.myController = function(){};
app.controller(controllers);
Take a look at this video http://egghead.io/video/angularjs-thinking-different-about-organization/
The whole series is amazing to be honest.
这篇关于替代语法angular.module.controller的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文