Reputation: 69
I'm trying to pass from directive to controller a function with 1 param but it alerts undefined.
myApp.controller('MyController', function($scope, $window) {
$scope.blabla = function(msg) { alert(msg) };
});
Lol :).Thanks
Upvotes: 0
Views: 1304
Reputation: 26841
You were passing a variable called hello
instead of "hello"
Here is an updated fiddle which works.
Here is the relevant part that changed
<div py="blabla('hello')">eqweq</div>
Notice the quotes around hello
Between you are not passing that function from the directive to the controller. You are in fact passing it the other way around (which is correct and fine ). If you are passing a function from directive to a controller there is something wrong there architecture wise.
Upvotes: 2