57 lines
1.1 KiB
Plaintext
57 lines
1.1 KiB
Plaintext
|
|
p.location-badge.
|
|
exported from <a href='../router'>angular2/router</a>
|
|
defined in <a href="https://github.com/angular/angular/tree/2.0.0-alpha.37/modules/angular2/src/core/di/opaque_token.ts#L1-L27">angular2/src/core/di/opaque_token.ts (line 1)</a>
|
|
|
|
:markdown
|
|
By binding to an `OpaqueToken` you can enable an application to return more meaningful error
|
|
messages.
|
|
|
|
## Example
|
|
|
|
```
|
|
// While the following would work, see below for the preferred way
|
|
var binding = bind('value0').toValue(0);
|
|
...
|
|
var value = injector.get('value0');
|
|
|
|
// An OpaqueToken is the preferred way and lead to more helpful error messages
|
|
export value0Token = new OpaqueToken('value0');
|
|
var binding = bind(value0Token).toValue(0);
|
|
...
|
|
var value = injector.get(value0Token);
|
|
```
|
|
|
|
|
|
|
|
.l-main-section
|
|
h2 Annotations
|
|
.l-main-section
|
|
h2 Members
|
|
.l-sub-section
|
|
h3#constructor constructor
|
|
|
|
|
|
pre.prettyprint
|
|
code.
|
|
constructor(_desc: string)
|
|
|
|
:markdown
|
|
|
|
|
|
|
|
|
|
.l-sub-section
|
|
h3#toString toString
|
|
|
|
|
|
pre.prettyprint
|
|
code.
|
|
toString()
|
|
|
|
:markdown
|
|
|
|
|
|
|
|
|