AngularJS directive calling a callback function -


i'm trying make dropdownlist directive, , want have attribute onitemselected="mycallbackfunction(selecteditem)", how can it? can provide example?

you can use & binding (isolate scope function expression binding)

.directive("sample", [function() {     return {         restrict: "a",         scope: {             myfunc: "&"         },         link: function(scope, elem, attrs) {             scope.myfunc(); //whenever wanna call         }    } }]) 

and html

<div sample my-func="somescopefunction()"></div> 

id recommend reading: https://gist.github.com/cmcdragonkai/6282750 directive binding explanations.


Comments

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

How to use Authorization & Authentication in Asp.net, C#? -