0
I am facing problems when assigning a 'click' event in an external template previously compiled, follow the code...
Directive
angular.module('testeFuncoes').directive('fechaMenu', function($templateRequest, $compile) {
return {
link: function(scope, element, attr) {
$templateRequest("template.html").then(function(html){
var template = angular.element(html);
element.html($compile(template)(scope));
var cnt = $(element).contents();
$(element).replaceWith(cnt);
$('.ctnTeste').trigger('click');
});
},
}
})
Template
<md-menu-bar>
<md-menu>
<div class="ctnTeste" ng-click="openMenu($mdMenu, ev)" style="display: flex; padding: 20px; background-color: black">
<div class="subTeste" style="padding:{{color.red}}px; background-color:rgb(1,10,{{color.red}});"></div>
<div class="subTeste" id="teste"></div>
</div>...
In other words, when injecting this template I want to simulate a click on it, but within the link function. When passing Rigger, it gives me the following error [$rootScope:inprog] $Digest already in Progress, but if I assign the event manually it works, example...
$('.testebotao').on('click', function() {
$('.ctnTeste').trigger('click');
})