Using 'controller as' with the ui-router isn't working as expected

后端 未结 5 844
耶瑟儿~
耶瑟儿~ 2021-02-02 10:35

I have the following state setup for a page using an abstract state and the controller as syntax:

# Details page route
.state \'title\', 
  url: \'/title\',
  ab         


        
5条回答
  •  臣服心动
    2021-02-02 11:11

    Seems like these answers might be working for a lot. I came here with a different problem :

    In my UI Router Javascript file, my controllers are defined like this :

    state('groupHome', {
         url: '/groupHome',
         templateUrl: 'app/modules/group-home/groupHome.html',
         controller: 'GroupHomeController',
         controllerAs: 'groupHomeController'
    

    And in my template file if I try to access the controller with the name groupHomeController it is not able to access.

    But on the other hand when I changed my code to this :

    state('groupHome', {
         url: '/groupHome',
         templateUrl: 'app/modules/group-home/groupHome.html',
         controller: 'GroupHomeController as groupHomeController'
    

    It works perfectly fine.

提交回复
热议问题