mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 07:40:22 +00:00
65 lines
2.3 KiB
Text
65 lines
2.3 KiB
Text
@ngdoc overview
|
|
@name Developer Guide: Initializing Angular
|
|
@description
|
|
|
|
Initializing Angular consists of loading the `angular.js` script in your page, and specifying how
|
|
Angular should process and manage the page. To initialize Angular you do the following:
|
|
|
|
* Specify the Angular namespace in the `<html>` page
|
|
* Choose which flavor of Angular script to load (debug or production)
|
|
* Specify whether or not Angular should process and manage the page automatically (`ngApp`)
|
|
|
|
The simplest way to initialize Angular is to load the Angular script and tell Angular to compile
|
|
and manage the whole page. You do this as follows:
|
|
|
|
<pre>
|
|
<!doctype html>
|
|
<html ng-app>
|
|
<head>
|
|
...
|
|
</head>
|
|
<body>
|
|
...
|
|
<script src="angular.js">
|
|
</body>
|
|
</pre>
|
|
|
|
|
|
## Specifying the Angular Namespace
|
|
|
|
<html xmlns:ng="http://angularjs.org">
|
|
|
|
You need to add the Angular namespace declaration if you use `ng:something` style of declaring
|
|
Angular directives and you write your templates as XHTML. Or when you are targeting Internet
|
|
Explorer older than version 9 (because older versions of IE do not render namespace
|
|
properly for either HTML or XHTML). For more info please read {@link ie Internet Explorer
|
|
Compatibility} doc.
|
|
|
|
|
|
## Creating Your Own Namespaces
|
|
|
|
When you are ready to define your own {@link guide/directive
|
|
directive}, you may chose to create your own namespace in addition to specifying the Angular
|
|
namespace. You use your own namespace to form the fully qualified name for directives that you
|
|
create.
|
|
|
|
For example, you could map the alias `my` to your domain, and create a directive called `my:directive`.
|
|
To create your own namespace, simply add another `xmlns` tag to your page, create an alias, and set
|
|
it to your unique domain:
|
|
|
|
<html xmlns:ng="http://angularjs.org" xmlns:my="http://mydomain.com">
|
|
|
|
|
|
## Loading the Angular Bootstrap Script
|
|
|
|
The Angular bootstrap script comes in two flavors; a debug script, and a production script:
|
|
|
|
* angular-[version].js - This is a human-readable file, suitable for development and debugging.
|
|
* angular-[version].min.js - This is a compressed and obfuscated file, suitable for use in
|
|
production.
|
|
|
|
|
|
## Related Topics
|
|
|
|
* {@link dev_guide.bootstrap.auto_bootstrap Automatic Initialization}
|
|
* {@link dev_guide.bootstrap.manual_bootstrap Manual Initialization}
|