假设您有一个 AngularJS 指令,您希望在其中将控制器属性和controllerAs属性设置为相同的字符串。
前任。
angular.module('blahModule', [])
.directive('blahDirective', function(){
return {
restrict: 'E',
controller: 'blahController',
controllerAs: 'blahController',
templateUrl: 'blah/blah.html'
}
});
以上是有效的并且有效,但是当将控制器和控制器的值设置为相同的东西时感觉是多余的。有没有办法在一个属性中做到这一点?喜欢:
angular.module('blahModule', [])
.directive('blahDirective', function(){
return {
restrict: 'E',
controllerAndControllerAs: 'blahController',
templateUrl: 'blah/blah.html'
}
});
提前致谢!