且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将回调函数传递给指令

更新时间:2023-11-09 23:52:46

在从指令中调用表达式方法时,您需要以 JSON 格式从指令中传递参数,还应该更正您的指令 callback 属性值传递函数,如 callback="onImageSelect(image)"

While calling the expression method from the directive you need to pass the parameter from the directive in JSON format, also you should correct your directive callback attribute value to pass function like callback="onImageSelect(image)"

指令用法:

<google-image-search callback="onImageSelect(image)" />

指令模板

<a data-ng-click="callback({image: url})"></a>