0
<h1 ng-controller="mainController as mainCtrl">{{ms}}</h1>
.controller("mainController",function(){
this.ms = "hi";
});
왜 angularjs에 as
을 사용하는 사람들이 있습니까? 내가 주로하는 일은 당신이은 angularjs에서 컨트롤러 사용에 대한 참조로 사용됩니다.
<h1 ng-controller="mainController as mainCtrl">{{mainCtrl.ms}}</h1>
app.controller("mainController", function() {
this.ms = "hi";
});
더 나은이 here을 설명한다면 당신은 $scope
을 주입 할 필요가 없습니다 $ 범위를 주입하고 $scope.ms = 'something'
이것은 새로운 것입니까? 그것이 바람직한 방법이라면 왜 공식적인 공식 사이트를 사용하지 않는 것이 좋습니까? –