0

I know this is a subject discussed too many times. I know that jQuery may create problems. I know most sites advise try to avoid the use of jQuery, however my question is: How may I manipulate the DOM inside an Angular directive if not using jQuery? Even in Angular docs there is intensive use of jQuery lite inside directives. I 'd appreciate your opinions in that.

1
  • use the second parameter of link function Commented Dec 15, 2016 at 16:47

1 Answer 1

0

In link function you can actually manipulate DOM.

app.directive('sampleDirective', function() {
    return {
        ...
        link: function(scope, ele, attr, ctrl) {
            //here actually you can manipulate DOM using ele.
        }
    }
})

Angular has bilt-in jqLite(subset of jQuery). Find it here.

Note: Do DOM manipulations only in directive.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.