0

I have an application that contains a div with content in it. When I click a button jQuery adds a AngularJs directive to the div. After adding the directive i call scope.$apply(), but this doesn't seem to inform angular about the new directive on the div. Can someone explain to me how I can inform AngularJs about the new directive added with jQuery?

2
  • 1
    You need to $compile the newly added Angular directive. See stackoverflow.com/a/12049456/215945 Commented Feb 12, 2013 at 16:27
  • Yeah... what Mark said. :P I think we have the same browsing habits, this happens once a day. Commented Feb 12, 2013 at 16:31

1 Answer 1

2

You shouldn't be adding directives to your markup with JQuery. Use Angular for that whenever possible.

That said, if you have to add directives via straight DOM manipulations like that, you'll need to use the $compile provider to compile the element and bind it to a scope before you add it.

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.