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

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -