javascript - Call a controller scope function from directive in Angular -


i have scope function inside controller, need trigger directive , directive dropdown, whenever changing value need trigger function directive controller.

html

<dropdown-single-select filter-params=false eventlstn="selecttab('summary')" api-params="serviceapiparams"  select-options="filterdata.classfilter" selected-value="filterdata.selectedclassoptions" ></dropdown-single-select> 

directive

.directive('dropdownsingleselect',['$document', function($document){     return {         scope: {           onselect: '&',                     selectoptions: '=',           isofilterparams:'=filterparams',           isoeventlistener:'=eventlistener',           selectedvalue:'=',           defaultoption:'=',           disable:'&',           apiparams:'='                },         restrict: 'e',         templateurl: 'commonactions/waggle-single-select.tpl.html',         link: function(scope, element, attr) {                        scope.toggleoptions= function(){                 scope.showoptions = !scope.showoptions;             }             scope.selectoption = function(option){                                 if(scope.apiparams.reload){                     scope.apiparams.classviewid=option.classviewid;                     scope.$apply(attr.eventlstn);                 }                     }     }; }]) 

controller

.controller('studentsummaryreportctrl', ['$scope', function ($scope){  $scope.selecttab=function(data){ console.log(data); }  }]) 

dropdown working fine , selectoption working fine when comes scope.$apply(attr.eventlstn); not working

add eventlstn : '&' , call when needed scope.$apply(scope.eventlstn(args))


Comments

Popular posts from this blog

timeout - Handshake_timeout on RabbitMQ using python and pika from remote vm -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

c# - Search and Add Comment with OpenXML for Word -