Angularjs Initialize the static template detailed _angularjs

Source: Internet
Author: User

Angularjs can be initiated by Ng-app from the dynamic initialization module or by Angular.bootstrap (document, [module]), regardless of the method, the DOM element that is dynamically added to the DOM tree after the application starts. Cannot execute the angular instruction, that is, how can I bind data and events to dynamically added DOM elements through Ng-model, Ng-click?

Dynamic add DOM elements of the scene is very common, such as clicking on a page to modify the user Information button, send an AJAX request to query the user information, and then through the template engine will be written in the page in advance of the static template into an HTML string, and finally the HTML string append to the page display, In general we would do this:

<! 
  DOCTYPE html>  

Click the Modify Data button, the newly inserted DOM element does not bind the Ajax returned data, because the angular has been initialized before clicking the button, the solution is not to initialize it once, but to use $compile to compile the HTML of the static template alone. Then insert the

in the DOM tree

<! 
  DOCTYPE html>  

The above is about ANGULARJS initialization static template detailed introduction, I hope to help you learn.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.