AngularJs “controller as” syntax - clarification?

后端 未结 6 623
面向向阳花
面向向阳花 2020-11-22 14:08

I read about the new syntax from angularJS regarding controller as xxx

The syntax InvoiceController as invoice tells Angular

6条回答
  •  迷失自我
    2020-11-22 14:48

    I find the main advantage is a more intuitive api since the methods/properties are associated with the controller instance directly and not the scope object. Basically, with the old approach, the controller becomes just a decorate for building up the scope object.

    Here are some more info on this: http://www.syntaxsuccess.com/viewarticle/551798f20c5f3f3c0ffcc9ff

提交回复
热议问题