앵귤러 부트 스트랩에서 경고를 추가하려고하는데 타임 아웃시 자체를 닫으려고합니다. 그러나 그것은 그 자체를 일축하지 않습니다. 다음은 코드입니다.앵귤러 부트 스트랩 경고가 타임 아웃시 해제되지 않습니다.
angular.module('ui.services').service('AlertService', [
function() {
var alerts = [];
this.add = function(type, msg){
var self = this;
return alerts.push({
type: type,
msg: msg,
close: function() {
return self.closeAlert(this);
}
});
$timeout(function(){
self.closeAlert(this);
}, 3000);
},
this.closeAlert = function(alert) {
return this.closeAlertIdx(alerts.indexOf(alert));
},
this.closeAlertIdx = function(index) {
return alerts.splice(index, 1);
},
this.alertData = function() {
return alerts;
}
}]);
무엇이 잘못 되었습니까?
(); 컨트롤러 B에서 AlertService.add ('success', 'this is deleted', true);로 표시 할 경고를 추가합니다. 그래서 경고 서비스 – looneytunes