我有一项服务,负责在屏幕上显示加载栏。我像这样动态添加加载栏
coreModule.provider('$loading', function () {
this.$get = ['$document', function ($document) {
var element = angular.element('<div id="loading" class="loading">' + '<img src="../styling/img/loading.gif" alt="loading .... ">' + '</div>');
return {
inProgress:function (message) {
$document.find('body').append(element);
},
finish:function () {
// $document.find('body').remove(element); <- does not work
// $document.find('body').remove('#loading'); <- neither this one does !!
}
}
}];
});
然而,完成功能确实起作用。它确实从身体中移除了元素。有什么想法吗?
答案 0 :(得分:10)
您可以使用element.remove()
- 请参阅http://docs.angularjs.org/api/angular.element了解可用的jQueryLight方法。