0

I am looking to include a div with ng-include="'abc.html'" into an HTML from a javascript. Please let me know how to add this as am facing issues to get the ng-include value within " ' ' ".

2
  • What is the goal of doing this? Commented Nov 6, 2012 at 19:05
  • try to escape the single quotes. i.e., instead of "''" use this "\'\'" Commented Nov 6, 2012 at 19:17

1 Answer 1

1

There are multiple ways of conditionally including partials in angular. Here are a few methods.

  1. Use ng-show / ng-hide to show or hide the element that is included using ng-include. This only achieves a show or hide and doesnt take it out of the DOM.

  2. Put an ng-switch on top of the ng-include div. Make changes to the variable that the switch observes and toggle the inclusion or non-inclusion using the ng-switch value.

  3. ng-include itself takes a variable. If you dont set that variable or set it to null, then it will not show anything until you change the value of the variable to point to your partial location.

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.