角元素删除不起作用? [英] Angular element remove does not work ?

查看:61
本文介绍了角元素删除不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一项服务,负责在屏幕上显示加载栏.我像这样

I have a service which is responsible for show a loading bar on the screen. I add the loading bar dynamically like this

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

但是结束功能确实起作用.它确实从身体上删除了元素.有什么想法吗?

However finish function does work at all. It does remove the element from the body. Any ideas ?

推荐答案

您可以使用element.remove()-请参见 http://docs.angularjs.org/api/angular.element 获取可用的jQueryLight方法.

You can use element.remove() - see http://docs.angularjs.org/api/angular.element for the available jQueryLight methods.

这篇关于角元素删除不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆