【问题标题】:Angular element remove does not work ?角元素删除不起作用?
【发布时间】:2013-05-21 06:47:12
【问题描述】:

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

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

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

【问题讨论】:

    标签: angularjs


    【解决方案1】:

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

    【讨论】:

    • 我是否也必须使用 $destroy 来杀死作用域?
    猜你喜欢
    • 2013-12-31
    • 2018-03-18
    • 2012-05-10
    • 1970-01-01
    • 2013-02-02
    • 1970-01-01
    • 1970-01-01
    • 2020-11-01
    • 1970-01-01
    相关资源
    最近更新 更多