mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-24 10:20:23 +00:00
fix(doc) cleanup all dev guide doc link warnings
This commit is contained in:
parent
186a840cd3
commit
035c751076
13 changed files with 93 additions and 101 deletions
|
|
@ -31,7 +31,7 @@ This is the sequence that your code should follow if you bootstrap angular on yo
|
|||
|
||||
1. After the page is loaded, find the root of the HTML template, which is typically the root of
|
||||
the document.
|
||||
2. Run angular's {@link dev_guide.compiler Angular HTML compiler}, which converts a template into
|
||||
2. Call {@link api/angular.bootstrap} to {@link dev_guide.compiler compile} the template into
|
||||
an executable, bi-directionally bound application.
|
||||
|
||||
|
||||
|
|
@ -43,4 +43,4 @@ an executable, bi-directionally bound application.
|
|||
|
||||
## Related API
|
||||
|
||||
{@link api/angular.compile Compiler API}
|
||||
{@link api/angular.module.NG.$compile Compiler API}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ angular.directive('ng:bind', function(expression, compiledElement) {
|
|||
The angular compiler exposes methods that you may need to use when writing your own widgets and
|
||||
directives. For example, the `descend()` method lets you control whether the compiler ignores or
|
||||
processes child elements of the element it is compiling. For information on this and other
|
||||
compiler methods, see the {@link api/angular.compile Compiler API doc}.
|
||||
compiler methods, see the {@link api/angular.module.NG.$compile Compiler API doc}.
|
||||
|
||||
|
||||
## Related Docs
|
||||
|
|
|
|||
|
|
@ -93,4 +93,4 @@ corresponding spans.
|
|||
|
||||
## Related API
|
||||
|
||||
* {@link api/angular.compile angular.compile()}
|
||||
* {@link api/angular.module.NG.$compile $compile()}
|
||||
|
|
|
|||
|
|
@ -89,4 +89,4 @@ angular.attrMarkup('extraClass', function(attrValue, attrName, element){
|
|||
|
||||
## Related API
|
||||
|
||||
* {@link api/angular.compile Compiler API Reference}
|
||||
* {@link api/angular.module.NG.$compile Compiler API Reference}
|
||||
|
|
|
|||
|
|
@ -23,4 +23,4 @@ All compilation takes place in the web browser; no server is involved.
|
|||
|
||||
## Related API
|
||||
|
||||
* {@link api/angular.compile Angular Compiler API}
|
||||
* {@link api/angular.module.NG.$compile Angular Compiler API}
|
||||
|
|
|
|||
|
|
@ -14,4 +14,4 @@
|
|||
|
||||
## Related API
|
||||
|
||||
* {@link api/angular.compile angular.compile()}
|
||||
* {@link api/angular.module.NG.$compile $compile()}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ dataset]"`), the link function gets called to set up a listener on each element
|
|||
|
||||
Note that angular's built-in widgets, directives, and markup have predefined compile and link
|
||||
functions that you don't need to modify. When you create your own widgets, directives, or markup,
|
||||
you must write compile and link functions for them. Refer to the {@link api/angular.compile
|
||||
you must write compile and link functions for them. Refer to the {@link api/angular.module.NG.$compile
|
||||
Compiler API} for details.
|
||||
|
||||
When the angular compiler compiles a page, it proceeds through 3 phases: Compile, Create Root
|
||||
|
|
@ -53,7 +53,7 @@ Note that while the compile function is executed exactly once, the link function
|
|||
multiple times, for example, once for each iteration in a repeater.
|
||||
|
||||
The angular compiler exposes methods that you will need to make use of when writing your own
|
||||
widgets and directives. For information on these methods, see the {@link api/angular.compile
|
||||
widgets and directives. For information on these methods, see the {@link api/angular.module.NG.$compile
|
||||
Compiler API doc}.
|
||||
|
||||
|
||||
|
|
@ -65,4 +65,4 @@ Compiler API doc}.
|
|||
|
||||
## Related API
|
||||
|
||||
* {@link api/angular.compile angular.compile()}
|
||||
* {@link api/angular.module.NG.$compile $compile()}
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ angular.widget('my:time', function(compileElement){
|
|||
The angular compiler exposes methods that you may need to use of when writing your own widgets and
|
||||
directives. For example, the `descend()` method lets you control whether the compiler ignores or
|
||||
processes child elements of the element it is compiling. For information on this and other
|
||||
compiler methods, see the {@link api/angular.compile Compiler API doc}.
|
||||
compiler methods, see the {@link api/angular.module.NG.$compile Compiler API doc}.
|
||||
|
||||
|
||||
## Related Topics
|
||||
|
|
@ -92,4 +92,4 @@ compiler methods, see the {@link api/angular.compile Compiler API doc}.
|
|||
|
||||
## Related API
|
||||
|
||||
* {@link api/angular.compile Compiler API}
|
||||
* {@link api/angular.module.NG.$compile Compiler API}
|
||||
|
|
|
|||
|
|
@ -32,4 +32,4 @@ dev_guide.compiler.widgets.creating_widgets Creating Custom Widgets}.
|
|||
|
||||
## Related API
|
||||
|
||||
* {@link api/angular.compile Compiler API}
|
||||
* {@link api/angular.module.NG.$compile Compiler API}
|
||||
|
|
|
|||
|
|
@ -243,4 +243,4 @@ so that angular developers and developers who use angular can develop in harmony
|
|||
|
||||
## Related API
|
||||
|
||||
* {@link api/angular.compile Angular Compiler API}
|
||||
* {@link api/angular.module.NG.$compile Angular Compiler API}
|
||||
|
|
|
|||
|
|
@ -23,9 +23,7 @@ available as `this` within the given context. (Note: This api will change before
|
|||
|
||||
### Root scope
|
||||
|
||||
Every application has a root scope, which is the ancestor of all other scopes. The root scope is
|
||||
responsible for creating the injector which is assigned to the {@link api/angular.module.NG.$rootScope.Scope#$service
|
||||
$service} property, and initializing the services.
|
||||
Every application has a root scope, which is the ancestor of all other scopes.
|
||||
|
||||
### What is scope used for?
|
||||
|
||||
|
|
@ -75,7 +73,7 @@ expect(root.name).toEqual('angular');
|
|||
### Scope life cycle
|
||||
1. **Creation**
|
||||
|
||||
* You can create the root scope via {@link api/angular.module.NG.$rootScope.Scope angular.module.NG.$rootScope.Scope()}.
|
||||
* The root scope is created by the {@link api/angular.module.NG.$rootScope $rootScope} service.
|
||||
* To create a child scopes, you should call {@link api/angular.module.NG.$rootScope.Scope#$new parentScope.$new()}.
|
||||
|
||||
2. **Watcher registration**
|
||||
|
|
@ -116,9 +114,6 @@ scopes come into play throughout and get a sense of their interactions.
|
|||
|
||||
1. At application compile time, a root scope is created and is attached to the root `<HTML>` DOM
|
||||
element.
|
||||
1. The root scope creates an {@link api/angular.injector injector} which is assigned to the
|
||||
{@link api/angular.module.NG.$rootScope.Scope#$service $service} property of the root scope.
|
||||
2. Any eager {@link api/angular.module.NG.$rootScope.Scope#$service services} are initialized at this point.
|
||||
2. During the compilation phase, the {@link dev_guide.compiler compiler} matches {@link
|
||||
api/angular.directive directives} against the DOM template. The directives usually fall into one of
|
||||
two categories:
|
||||
|
|
@ -209,9 +204,14 @@ When you find it necessary to inject your own mocks in your tests, use a scope t
|
|||
service instances, as shown in the following example.
|
||||
|
||||
<pre>
|
||||
var myLocation = {};
|
||||
var scope = angular.module.NG.$rootScope.Scope(angular.module.NG, {$location: myLocation});
|
||||
expect(scope.$service('$location')).toEqual(myLocation);
|
||||
it('should allow override of providers', inject(
|
||||
function($provide) {
|
||||
$provide.value('$location', {mode:'I am a mock'});
|
||||
},
|
||||
function($location){
|
||||
expect($location.mode).toBe('I am a mock');
|
||||
}
|
||||
)};
|
||||
</pre>
|
||||
|
||||
## Related Topics
|
||||
|
|
|
|||
|
|
@ -88,9 +88,8 @@ setter methods that allow you to get or change the current URL in the browser.
|
|||
|
||||
## $location service configuration
|
||||
|
||||
To configure the `$location` service, you get a hold of
|
||||
{@link angular.module.ng.$locationProvider $locationProvider} service and configure it with these
|
||||
methods:
|
||||
To configure the `$location` service, retrieve the
|
||||
{@link api/angular.module.NG.$locationProvider $locationProvider} and set the parameters as follows:
|
||||
|
||||
- **html5Mode(mode)**: {boolean}<br />
|
||||
`true` - see HTML5 mode<br />
|
||||
|
|
@ -210,26 +209,27 @@ In this mode, `$location` uses Hashbang URLs in all browsers.
|
|||
### Example
|
||||
|
||||
<pre>
|
||||
angular.module.NG('$locationConfig', function() {
|
||||
return {
|
||||
html5Mode: false,
|
||||
hashPrefix: '!'
|
||||
};
|
||||
});
|
||||
it('should show example', inject(
|
||||
function($locationProvider) {
|
||||
$locationProvider.html5mode = false;
|
||||
$locationProvider.hashPrefix = '!';
|
||||
},
|
||||
function($location) {
|
||||
// open http://host.com/base/index.html#!/a
|
||||
$location.absUrl() == 'http://host.com/base/index.html#!/a'
|
||||
$location.path() == '/a'
|
||||
|
||||
// open http://host.com/base/index.html#!/a
|
||||
$location.absUrl() == 'http://host.com/base/index.html#!/a'
|
||||
$location.path() == '/a'
|
||||
$location.path('/foo')
|
||||
$location.absUrl() == 'http://host.com/base/index.html#!/foo'
|
||||
|
||||
$location.path('/foo')
|
||||
$location.absUrl() == 'http://host.com/base/index.html#!/foo'
|
||||
$location.search() == {}
|
||||
$location.search({a: 'b', c: true});
|
||||
$location.absUrl() == 'http://host.com/base/index.html#!/foo?a=b&c'
|
||||
|
||||
$location.search() == {}
|
||||
$location.search({a: 'b', c: true});
|
||||
$location.absUrl() == 'http://host.com/base/index.html#!/foo?a=b&c'
|
||||
|
||||
$location.path('/new').search('x=y');
|
||||
$location.absUrl() == 'http://host.com/base/index.html#!/new?x=y'
|
||||
$location.path('/new').search('x=y');
|
||||
$location.absUrl() == 'http://host.com/base/index.html#!/new?x=y'
|
||||
}
|
||||
));
|
||||
</pre>
|
||||
|
||||
### Crawling your app
|
||||
|
|
@ -258,39 +258,40 @@ having to worry about whether the browser displaying your app supports the histo
|
|||
### Example
|
||||
|
||||
<pre>
|
||||
angular.module.NG('$locationConfig', function() {
|
||||
return {
|
||||
html5Mode: true,
|
||||
hashPrefix: '!'
|
||||
};
|
||||
});
|
||||
it('should show example', inject(
|
||||
function($locationProvider) {
|
||||
$locationProvider.html5mode = true;
|
||||
$locationProvider.hashPrefix = '!';
|
||||
},
|
||||
function($location) {
|
||||
// in browser with HTML5 history support:
|
||||
// open http://host.com/#!/a -> rewrite to http://host.com/a
|
||||
// (replacing the http://host.com/#!/a history record)
|
||||
$location.path() == '/a'
|
||||
|
||||
// in browser with HTML5 history support:
|
||||
// open http://host.com/#!/a -> rewrite to http://host.com/a
|
||||
// (replacing the http://host.com/#!/a history record)
|
||||
$location.path() == '/a'
|
||||
$location.path('/foo');
|
||||
$location.absUrl() == 'http://host.com/foo'
|
||||
|
||||
$location.path('/foo');
|
||||
$location.absUrl() == 'http://host.com/foo'
|
||||
$location.search() == {}
|
||||
$location.search({a: 'b', c: true});
|
||||
$location.absUrl() == 'http://host.com/foo?a=b&c'
|
||||
|
||||
$location.search() == {}
|
||||
$location.search({a: 'b', c: true});
|
||||
$location.absUrl() == 'http://host.com/foo?a=b&c'
|
||||
$location.path('/new').search('x=y');
|
||||
$location.url() == 'new?x=y'
|
||||
$location.absUrl() == 'http://host.com/new?x=y'
|
||||
|
||||
$location.path('/new').search('x=y');
|
||||
$location.url() == 'new?x=y'
|
||||
$location.absUrl() == 'http://host.com/new?x=y'
|
||||
// in browser without html5 history support:
|
||||
// open http://host.com/new?x=y -> redirect to http://host.com/#!/new?x=y
|
||||
// (again replacing the http://host.com/new?x=y history item)
|
||||
$location.path() == '/new'
|
||||
$location.search() == {x: 'y'}
|
||||
|
||||
// in browser without html5 history support:
|
||||
// open http://host.com/new?x=y -> redirect to http://host.com/#!/new?x=y
|
||||
// (again replacing the http://host.com/new?x=y history item)
|
||||
$location.path() == '/new'
|
||||
$location.search() == {x: 'y'}
|
||||
|
||||
$location.path('/foo/bar');
|
||||
$location.path() == '/foo/bar'
|
||||
$location.url() == '/foo/bar?x=y'
|
||||
$location.absUrl() == 'http://host.com/#!/foo/bar?x=y'
|
||||
$location.path('/foo/bar');
|
||||
$location.path() == '/foo/bar'
|
||||
$location.url() == '/foo/bar?x=y'
|
||||
$location.absUrl() == 'http://host.com/#!/foo/bar?x=y'
|
||||
}
|
||||
));
|
||||
</pre>
|
||||
|
||||
### Fallback for legacy browsers
|
||||
|
|
@ -364,7 +365,6 @@ redirect to regular / hashbang url, as this conversion happens only during parsi
|
|||
= on page reload.
|
||||
|
||||
In this examples we use `<base href="/base/index.html" />`
|
||||
|
||||
<doc:example>
|
||||
<doc:source source="false">
|
||||
|
||||
|
|
@ -422,8 +422,7 @@ In this examples we use `<base href="/base/index.html" />`
|
|||
|
||||
var browsers = {
|
||||
html5: new FakeBrowser('http://www.host.com/base/path?a=b#h', '/base/index.html'),
|
||||
hashbang: new FakeBrowser('http://www.host.com/base/index.html#!/path?a=b#h',
|
||||
'/base/index.html')
|
||||
hashbang: new FakeBrowser('http://www.host.com/base/index.html#!/path?a=b#h', '/base/index.html')
|
||||
};
|
||||
|
||||
function Html5Cntl($location) {
|
||||
|
|
@ -461,14 +460,14 @@ In this examples we use `<base href="/base/index.html" />`
|
|||
|
||||
function initEnv(name) {
|
||||
var root = angular.element(document.getElementById(name + '-mode'));
|
||||
var scope = angular.module.NG.$rootScope.Scope(null, {
|
||||
$locationConfig: {html5Mode: true, hashPrefix: '!'},
|
||||
$browser: browsers[name],
|
||||
$document: root,
|
||||
$sniffer: {history: name == 'html5'}
|
||||
});
|
||||
|
||||
angular.compile(root)(scope).$apply();
|
||||
angular.bootstrap(root, [function($locationProvider, $provide){
|
||||
$locationProvider.html5Mode = true;
|
||||
$locationProvider.hashPrefix = '!';
|
||||
|
||||
$provide.value('$browser', browsers[name]);
|
||||
$provide.value('$document', root);
|
||||
$provide.value('$sniffer', {history: name == 'html5'});
|
||||
}]);
|
||||
root.bind('click', function(e) {
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
|
@ -515,26 +514,20 @@ When using `$location` service during testing, you are outside of the angular's
|
|||
api/angular.module.NG.$rootScope.Scope scope} life-cycle. This means it's your responsibility to call `scope.$apply()`.
|
||||
|
||||
<pre>
|
||||
angular.module.NG('$serviceUnderTest', function($location) {
|
||||
// whatever it does...
|
||||
};
|
||||
|
||||
describe('$serviceUnderTest', function() {
|
||||
var scope, $location, $sut;
|
||||
|
||||
beforeEach(function() {
|
||||
scope = angular.module.NG.$rootScope.Scope();
|
||||
$location = scope.$service('$location');
|
||||
$sut = scope.$service('$serviceUnderTest');
|
||||
describe('serviceUnderTest', function() {
|
||||
beforeEach(inject(function($provide) {
|
||||
$provide.factory('serviceUnderTest', function($location){
|
||||
// whatever it does...
|
||||
});
|
||||
});
|
||||
|
||||
it('should...', function() {
|
||||
it('should...', inject(function($location, $rootScope, serviceUnderTest) {
|
||||
$location.path('/new/path');
|
||||
scope.$apply();
|
||||
$rootScope.$apply();
|
||||
|
||||
// test whatever the service should do...
|
||||
|
||||
});
|
||||
}));
|
||||
});
|
||||
</pre>
|
||||
|
||||
|
|
|
|||
|
|
@ -2,12 +2,11 @@
|
|||
@name Developer Guide: Angular Services: Registering Angular Services
|
||||
@description
|
||||
|
||||
To register a service, register a factory function that creates the service with angular's
|
||||
Injector. The Injector is exposed as {@link api/angular.module.NG.$rootScope.Scope#$service scope.$service}. The
|
||||
following pseudo-code shows a simple service registration:
|
||||
To register a service, retrieve the {@link api/angular.module.AUTO.$provide $provide} service and use one of itse
|
||||
registration methods for new service declaration. The following pseudo-code shows a simple service registration:
|
||||
|
||||
<pre>
|
||||
angular.module.NG('service id', function() {
|
||||
$provide.factory('service id', function() {
|
||||
var shinyNewServiceInstance;
|
||||
//factory function body that constructs shinyNewServiceInstance
|
||||
return shinyNewServiceInstance;
|
||||
|
|
|
|||
Loading…
Reference in a new issue