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

后端 未结 5 963
耶瑟儿~
耶瑟儿~ 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:09

    If this helps anyone my problem came about from using templated views but specifying the controllerAs outside the views element. This took forever to figure out. Credit to this thread https://github.com/driftyco/ionic/issues/3058

    ** WRONG **

    views: {'content@': { templateUrl: 'views/listing.html' }},
    controller: 'ListingCtrl',
    controllerAs: 'ctrl'
    

    ** RIGHT **

    views: {
      'content@': { templateUrl: 'views/listing.html' },
       controller: 'ListingCtrl',
       controllerAs: 'ctrl'
    }
    

提交回复
热议问题