angular how to define multiple controllers

好久不见. 提交于 2019-12-11 00:46:53

问题


i have code like this

angular.module('mywidget', ['$scope']).controller('TestController', testController);

I want to add another controller to it ..say ...controller("Test2Controller",Test2Controller)

just wanted to know how we can achieve this ?


回答1:


You can

var myApp = angular.module('mywidget', ['$scope']);
myApp.controller('TestController', testController);
myApp.controller('Test2Controller', test2Controller);


来源:https://stackoverflow.com/questions/18100755/angular-how-to-define-multiple-controllers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!