This article mainly introduces AngularJS static initialization templates. There are two ways for AngularJS to initialize static templates. One is to use ng-app to automatically initialize modules, or you can use angular. bootstrap (document, [module]) manually starts the application. For more information, see AngularJS. You can use ng-app to automatically initialize the module or angular. bootstrap (document, [module]) manually starts the application. No matter which method is used, after the application is started, the dom elements dynamically added to the dom tree cannot execute angular commands, I cannot bind data and events to the dynamically added dom elements through ng-model or ng-click. What should I do?
It is very common to dynamically add dom elements. For example, you can click the modify user data button on a page to send an ajax request to query user data, then, use the template engine to compile the static template written on the page into an HTML string, and append the HTML string to the page. In general, we will do this:
Demo