I have an issue with one of our custom directive (alert-animate) not being displayed.
The issue occurs after the popinState
changes to inprogress
and back to update
. Somehow the custom directive does not show...
I have debugged the app and the directive's link function is indeed called. I cannot figure out why the directive is not beeing displayed though...
alert-animate directive definition:
(function () {
angular.module('commonModule').directive('alertAnimate', function ($animate, $timeout, $rootScope) {
return {
restrict : 'E',
replace : true,
scope : {
type : '@',
zone : '@',
timeout : '@'
},
link : function (scope, iElement) {
// if there is no timeout defined, we fix it to 5 second
if (angular.isUndefined(scope.timeout)) {
scope.timeout = 5000;
}
$rootScope.$on(scope.zone + '::' + scope.type, function (e, message) {
// Create alert div
var messageElement = angular.element('<div class="alert alert-' + scope.type + '"></div>');
messageElement.append(message);
iElement.empty();
iElement.append(messageElement);
// create animation after the delay
$timeout(function () {
$animate.leave(messageElement);
}, scope.timeout);
});
}
};
});
})();
alert-animate usage within an ng-if directive:
<div ng-if="popinState['save-mappings'] === 'update'">
<div class="modal-body">
<fieldset class="marginb">
<legend>Modifier</legend>
<alert-animate type="danger" zone="POPIN_SAVE"></alert-animate>
...
</div>
</div>
<div ng-if="popinState['save-mappings'] === 'inprogress'">
<div class="modal-body">
<uib-progressbar min="0" max="100" value="100" class="progress-striped active">Le mapping est en cours d'enregistrement...</uib-progressbar>
</div>
</div>
This is how the error message is shown:
$scope.showErrorMessage = function (zone, message) {
$rootScope.$broadcast(zone + '::danger', message);
};
edit: The markup <alert-animate type="danger" zone="POPIN_SAVE"></alert-animate>
does show in the chrome console's sources but it is the error message that does not show.