Reputation: 3555
I've forked some code on Plunker in AngularJS and am trying to rewrite it with John Papa's conventions in mind.
I get an error:
Argument 'testCtrl as ctrl' is not a function, got undefined
Why ?
(function() {
angular.module('Test', [])
.controller('testCtrl', testCtrl)
.directive('testDirective', testDirective);
function testCtrl() {
var vm = this;
vm.options = {};
vm.callMe = function() {
console.log("called from crontroller");
vm.options.method1("something");
};
}
function testDirective() {
return {
restrict: "E",
scope: {
options: '='
},
link: function(scope, element, attrs) {
scope.options.method1 = function(message) {
console.log("called from crontroller: " + message);
}
}
}
}
}());
Upvotes: 2
Views: 165
Reputation: 95048
The version of Angular used in your plunkr doesn't support ControllerAs, update it to a newer version.
Upvotes: 1