Can I pass multiple controllers in $routeProvider.when() in angularJS?

后端 未结 1 1655
我在风中等你
我在风中等你 2020-12-09 22:54

I tried searching for this on various threads, but I can\'t conclusively understand this.

test.config([\'$routeProvider\', function($routeProvider){
$routePr         


        
相关标签:
1条回答
  • 2020-12-09 23:26

    Only one controller is allowed and will be assigned to the loading template as the controller in ng-view. No need to define ng-controller in the template for a main controller.

    If you need to define multiple controllers I suggest you define one main/parent controller and use that in the routeProvider and then have others already in the template using the ng-controller directive.

    or...

    Check into using Angular UI's UI-Router : http://angular-ui.github.io/ which is a much more versatile router.

    0 讨论(0)
提交回复
热议问题