search

Home  >  Q&A  >  body text

javascript - angularjs 引入 controller as 的疑问?

之前了解过1.2x版本引入了controller as 的语法。


var app = angular.module('app', []);

app.controller('demoController', [function(){
    this.title = 'angular';
}])


html: 

<p ng-app="app" ng-controller="demoController as demo">
    hello: {{demo.title}}
</p>

引入这个语法糖有什么作用呢?以及不同的适用场景?

PHP中文网PHP中文网2774 days ago534

reply all(1)I'll reply

  • 黄舟

    黄舟2017-04-10 16:16:03

    http://stackoverflow.com/questions/11605917/this-vs-scope-in-angularjs-controllers

    http://www.cnblogs.com/whitewolf/p/3493362.html

    reply
    0
  • Cancelreply