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

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

    Your controller needs to return the value of this in order for the controllerAs feature to work properly. Since CoffeeScript implicitly returns the last line, you need to write:

    return this
    

    or if you are using the vm syntax and have written:

    vm = this
    

    you can write at the very end of the controller:

    return vm
    

提交回复
热议问题