Reputation: 9
MY project having custom services body binded to click event, when clicked on body in service need to call resetDropdown() function in custom directive. how can i do please help me bro?
I tried code bellow that is first one is custom directive contain method.
.directive('dropdownMenu', ['$parse', '$compile', 'DropdownService', '$templateCache', function ($parse, $compile, DropdownService, $templateCache) { return { restrict: 'A', replace: false, ngTransclude:true, scope: { dropdownMenu: '=', dropdownModel: '=', dropdownItemLabel: '@', dropdownOnchange: '&', dropdownDisabled: '=', dropdownSubmit: '&' },
$scope.resetDropdown = function(){
alert("calling reset Dropdown by me");
}
}
}); next custom service having code .factory('DropdownService', ['$document', function ($document, $rootScope, $scope) { var body = $document.find('body'),
body.bind('click', function (event, $scope, $rootScope) {
resetDropdown();
});
when body clicked resetDropdown method need to call how can i do please help me.
Upvotes: 0
Views: 112
Reputation: 13
I don't know exactly what is required. But your directive method is in $scope and you are trying to call method in $rootScope.
Upvotes: 0