Configure one or more Ng-app on the same page in Angularjs

Source: Internet
Author: User

In Angularjs learning, the use of a Angularjs program property for Ng-app initialization needs to be noted that ANGULARJS automatically loads the first Ng-app in one page, and the other Ng-app is ignored,

If you need to load other Ng-app programs, you need to add the initialization process manually.

Manually initialize other Ng-app JavaScript code angular.bootstrap (document.getElementById ("id"), [' ID ']);

<DivNg-app= "MYAPP"Ng-controller= "Myctrl">    <inputtype= "text"Ng-model= "First"/>    <inputtype= "text"Ng-model= "Last"/>    <BR/>Name: {first + "+ Last}}</Div><DivID= "UserForm"Ng-app= "UserForm"Ng-controller= "Usercontroller">    <inputtype= "text"Ng-model= "username"/><BR/>    <inputtype= "text"Ng-model= "Password"/><BR/>User name: {{username}}<BR/>Password: {{password}}</Div>
<script type= "Text/javascript" >    var app = Angular.module ("myApp", []);    App.controller ("Myctrl",function($scope) {        = "Test";         = "Test";    });     var userapp = Angular.module ("UserForm", []);    Userapp.controller ("Usercontroller",function($scope) {        = "Test";         = "Test";    });    Angular.bootstrap (document.getElementById ("UserForm"), [' UserForm ']); </script>

Configure one or more Ng-app

on the same page in Angularjs

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.