javascript - angularjs 引入 controller as 的疑问?
PHP中文网
PHP中文网 2017-04-10 16:14:03
0
1
533

之前了解过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中文网

认证0级讲师

reply all(1)
黄舟

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

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!