7

我有一项服务负责在屏幕上显示加载栏。我像这样动态添加加载栏

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

但是完成功能确实有效。它确实从正文中删除了元素。有任何想法吗 ?

4

1 回答 1

10

您可以使用element.remove()- 请参阅http://docs.angularjs.org/api/angular.element了解可用的 jQueryLight 方法。

于 2013-05-21T07:25:48.180 回答