(iv) on the Ng-app automatic bootstrap framework

Source: Internet
Author: User

Previous blog (iii) the use of Ng-app and the automatic loading of the ANGULARJS framework presented the use of Ng-app directives. It was strange to think of the 4th and 5th cases, because we saw only the phenomenon and didn't see the essence. JS error, the most intuitive way to behave is: pop up a very unfriendly JS error window. The browser will not pop up the error message when the script has an uncaught error. There is also a more obscure indication: output error messages in the browser's console. This prompts us: when using the JS frame, be sure to use the next F12 to see if the console has errors .

3rd case and 5th case: Ng-app module without attributes can not be loaded automatically, with F12 to find the console error:

SCRIPT5022: [$injector: Modulerr] Failed to instantiate module App1 due to:
Error: [$injector: Nomod] Module ' App1 ' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that specify the dependencies as the second argument.

What do you mean? Presumably we used Ng-app to automatically load our custom modules, but we didn't provide those modules. Take a look at the official Ngapp documentation:

Use this directive to auto-bootstrap an AngularJS application. The Ngapp directive designates the root element of the application and is typically placed near the root element of the PA Ge-e.g. On the <body> or

1, if the NG-APP is defined in HTML, then the angular framework will be initialized automatically, regardless of whether it has a property value;

If you do not use Ng-app, you need to manually initialize it yourself.

2. If Ng-app does not have a property value, angular will create a module as root by default and then start the framework.

3, Ng-app Property If there is a value, that is, the custom module, it will be resolved, if we must first create the module.

That is, Ng-app is used to automatically start the angular framework, whether the difference between the value of the attribute is: the creation of the root module, in the end is the default, or we customize.

(iv) on the Ng-app automatic bootstrap framework

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.