Rumah > Soal Jawab > teks badan
之前了解过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>
引入这个语法糖有什么作用呢?以及不同的适用场景?
黄舟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