2013-07-23 16 views
4

在AngularJS我創建了一個服務:AngularJS警報服務:淡出NG-重複項

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 = []; 
}); 

並實現我的HTML代碼:

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

它消失在完全正常的,但不是簡單地「突然」出現在表格後,我想獲取元素,然後使用element.fadeOut()(jquery)

我無法獲得實際的警報元素。

+0

你也可以在角度js中使用指令概念嘗試使用flash消息http://angulartutorial.blogspot.in/2014/03/flash-message-using-directive-in.html – Prashobh

回答