Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular element remove does not work ?

Tags:

angularjs

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 ?

like image 551
Adelin Avatar asked May 21 '13 06:05

Adelin


People also ask

How to remove html element in DOM?

HTML DOM Element remove() The remove() method removes an element (or node) from the document.

How to remove DOM element js?

Use the removeChild() or remove() method to remove an element from the DOM.


1 Answers

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

like image 97
joakimbl Avatar answered Sep 21 '22 12:09

joakimbl