AngularJS Alert service: ng-repeat item attenuation

In AngularJS, I created a service:

services.service('Alerts', function($rootScope, $timeout) { this.add = function(content) { $rootScope.alerts.push({ content: content }); $timeout(function () { $rootScope.alerts.pop(); console.log($rootScope.alerts[0]); }, 1000); } }).run(function($rootScope) { $rootScope.alerts = []; }); 

and implemented my HTML code:

 <div class="alerts"> <div class="alert fade" ng-repeat="alert in alerts" bs-alert="alert"></div> </div> 

It disappears completely, but instead of just “popping out” of the table in a second, I would like to get the element and then use element.fadeOut () (jquery)

I cannot get a valid warning element.

+4
source share
1 answer

I tried to do something very similar, and here is what I came up with using the timeout service, although I did not use jQuery at all. http://plnkr.co/edit/Mi0xaPJa6pLWkBq60Ohn?p=preview

Obviously the css animation needs a little work, but I basically copied it from angular ng-repeat docs .

0
source

Source: https://habr.com/ru/post/1492883/


All Articles