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

android - Pass an Serializable object in AIDL -

php - Improving script execution time -

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