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