EntularJS implements the element before the method without jQuery

Is there an easy way to implement the up method for manipulating the DOM without jQuery in my AngularJS directive?

JQuery method:

$element.before($insertedBeforeElement);
+4
source share
2 answers

To do this without jQuery, but with angular jqLite:

$element.parent()[0].insertBefore($insertedBeforeElement[0], $element[0]);
+8
source

jqLite supports .after(), so you can use this to shuffle a little.

$element.after($insertedBeforeElement); //add it after
$insertedBeforeElement.after($element); //now switch the positions
+1
source

Source: https://habr.com/ru/post/1527014/


All Articles