我的項目有自定義服務體綁定到點擊事件,當點擊服務正文需要調用resetDropdown()函數在自定義指令。我該怎麼做,請幫助我兄弟?如何調用自定義服務中的方法自定義服務點擊事件中的角js?
I tried code bellow that is first one is custom directive contain method.
.directive( 'dropdownMenu',[ '$解析', '$編譯', 'DropdownService', '$ templateCache', 函數($解析,$編譯,DropdownService,$ templateCache){ 返回{ 限制: 'A', 取代:假, ngTransclude:真, 範圍:{ dropdownMenu: '=', dropdownModel: '=', dropdownItemLabel: '@', dropdownOnchange: '&' , dropdownDisabled:'=', dropdownSubmit:'&' },
$scope.resetDropdown = function(){
alert("calling reset Dropdown by me");
}
}
}); 下一定製服務具有代碼 .factory( 'DropdownService',[ '$文件', 函數($文件,$ rootScope,$範圍){ 變種體= $ document.find( '主體'),
body.bind('click', function (event, $scope, $rootScope) {
resetDropdown();
});
when body clicked resetDropdown method need to call how can i do please help me.
怎麼點擊samthing? –