Ich verwende controllerAs
auf meine Anweisung und verwendet bindToController
. Aber der Parameter bindToController ist auf dem Controller nicht definiert. DEMOangularjs bindToController Wert ist nicht definiert in Controller
var myApp = angular.module('myApp',[]);
myApp.controller('MyController', function($scope){
$scope.change = function(){
$scope.fullname = 'Brian Kim';
}
});
myApp.directive('myDirective', function() {
return {
restrict: 'E',
scope: {
name: '='
},
controller: function() {
console.log(this.name); // undefined
},
controllerAs: 'ctrl',
bindToController: true,
template: '{{ctrl.name}}',
};
});
wie einen Parameter bei der Initialisierung zugreifen kann? ich brauche es – barteloma