chore(examples): Updated live example links to use helper directive
closes #2005
This commit is contained in:
parent
531d6a8bce
commit
b93fb12fea
@ -26,8 +26,8 @@ include ../../../../_includes/_util-fns
|
|||||||
|
|
||||||
[Host and Query Metadata](#other-property-metadata)
|
[Host and Query Metadata](#other-property-metadata)
|
||||||
|
|
||||||
**Run and compare the live [TypeScript](/resources/live-examples/cb-ts-to-js/ts/plnkr.html) and
|
**Run and compare the live <live-example name="cb-ts-to-js">TypeScript</live-example> and <live-example name="cb-ts-to-js" lang="js">JavaScript</live-example>
|
||||||
[JavaScript](/resources/live-examples/cb-ts-to-js/js/plnkr.html) code shown in this cookbook.**
|
code shown in this cookbook.**
|
||||||
|
|
||||||
a(id="modularity")
|
a(id="modularity")
|
||||||
.l-main-section
|
.l-main-section
|
||||||
|
@ -35,7 +35,8 @@ include ../_util-fns
|
|||||||
|
|
||||||
- How to share information across controls with template local variables
|
- How to share information across controls with template local variables
|
||||||
|
|
||||||
[Live Example](/resources/live-examples/forms-deprecated/js/plnkr.html)
|
<live-example>Live Example</live-example>
|
||||||
|
|
||||||
.l-main-section
|
.l-main-section
|
||||||
:marked
|
:marked
|
||||||
## Template-Driven Forms
|
## Template-Driven Forms
|
||||||
|
@ -35,7 +35,7 @@ include ../_util-fns
|
|||||||
|
|
||||||
- How to share information across controls with template local variables
|
- How to share information across controls with template local variables
|
||||||
|
|
||||||
[Live Example](/resources/live-examples/forms/js/plnkr.html)
|
<live-example>Live Example</live-example>
|
||||||
|
|
||||||
.l-main-section
|
.l-main-section
|
||||||
:marked
|
:marked
|
||||||
|
@ -13,7 +13,7 @@ include _util-fns
|
|||||||
:marked
|
:marked
|
||||||
## See It Run!
|
## See It Run!
|
||||||
|
|
||||||
Running the [live example](/resources/live-examples/quickstart/js/plnkr.html)
|
Running the <live-example></live-example>
|
||||||
is the quickest way to see an Angular 2 app come to life.
|
is the quickest way to see an Angular 2 app come to life.
|
||||||
|
|
||||||
Clicking that link fires up a browser, loads the sample in [plunker](http://plnkr.co/ "Plunker"),
|
Clicking that link fires up a browser, loads the sample in [plunker](http://plnkr.co/ "Plunker"),
|
||||||
|
@ -6,7 +6,7 @@ a(id="top")
|
|||||||
syntax and its equivalent in Angular 2.
|
syntax and its equivalent in Angular 2.
|
||||||
|
|
||||||
:marked
|
:marked
|
||||||
**See the Angular 2 syntax in this [live example](/resources/live-examples/cb-a1-a2-quick-reference/ts/plnkr.html)**.
|
**See the Angular 2 syntax in this <live-example name="cb-a1-a2-quick-reference"></live-example>**.
|
||||||
|
|
||||||
## Contents
|
## Contents
|
||||||
This chapter covers
|
This chapter covers
|
||||||
|
@ -30,7 +30,7 @@ include ../_util-fns
|
|||||||
[Parent and children communicate via a service](#bidirectional-service)
|
[Parent and children communicate via a service](#bidirectional-service)
|
||||||
|
|
||||||
:marked
|
:marked
|
||||||
**See the [live example](/resources/live-examples/cb-component-communication/ts/plnkr.html)**.
|
**See the <live-example name="cb-component-communication"></live-example>**.
|
||||||
|
|
||||||
.l-main-section
|
.l-main-section
|
||||||
<a id="parent-to-child"></a>
|
<a id="parent-to-child"></a>
|
||||||
|
@ -75,7 +75,7 @@ include ../_util-fns
|
|||||||
:marked
|
:marked
|
||||||
## Source
|
## Source
|
||||||
|
|
||||||
**We can see the [live example](/resources/live-examples/cb-component-relative-paths/ts/plnkr.html)**
|
**We can see the <live-example name="cb-component-relative-paths"></live-example>**
|
||||||
and download the source code from there
|
and download the source code from there
|
||||||
or simply read the pertinent source here.
|
or simply read the pertinent source here.
|
||||||
+makeTabs(
|
+makeTabs(
|
||||||
|
@ -45,7 +45,7 @@ include ../_util-fns
|
|||||||
[Break circularities with a forward class reference (*forwardRef*)](#forwardref)
|
[Break circularities with a forward class reference (*forwardRef*)](#forwardref)
|
||||||
|
|
||||||
:marked
|
:marked
|
||||||
**See the [live example](/resources/live-examples/cb-dependency-injection/ts/plnkr.html)**
|
**See the <live-example name="cb-dependency-injection"></live-example>**
|
||||||
of the code supporting this cookbook.
|
of the code supporting this cookbook.
|
||||||
|
|
||||||
.l-main-section
|
.l-main-section
|
||||||
@ -236,7 +236,7 @@ figure.image-display
|
|||||||
The getter for the `hero` property pulls the cached hero from the service.
|
The getter for the `hero` property pulls the cached hero from the service.
|
||||||
And the template displays this data-bound property.
|
And the template displays this data-bound property.
|
||||||
|
|
||||||
Find this example in [live code](/resources/live-examples/cb-dependency-injection/ts/plnkr.html)
|
Find this example in <live-example name="cb-dependency-injection">live code</live-example>
|
||||||
and confirm that the three `HeroBioComponent` instances have their own cached hero data.
|
and confirm that the three `HeroBioComponent` instances have their own cached hero data.
|
||||||
figure.image-display
|
figure.image-display
|
||||||
img(src="/resources/images/cookbooks/dependency-injection/hero-bios.png" alt="Bios")
|
img(src="/resources/images/cookbooks/dependency-injection/hero-bios.png" alt="Bios")
|
||||||
@ -535,7 +535,7 @@ a(id='usefactory')
|
|||||||
:marked
|
:marked
|
||||||
The function retrieves candidate heroes from the `HeroService`,
|
The function retrieves candidate heroes from the `HeroService`,
|
||||||
takes `2` of them to be the runners-up, and returns their concatenated names.
|
takes `2` of them to be the runners-up, and returns their concatenated names.
|
||||||
Look at the [live example](/resources/live-examples/cb-dependency-injection/ts/plnkr.html)
|
Look at the <live-example name="cb-dependency-injection"></live-example>
|
||||||
for the full source code.
|
for the full source code.
|
||||||
|
|
||||||
a(id="tokens")
|
a(id="tokens")
|
||||||
@ -703,7 +703,7 @@ a(id='alex')
|
|||||||
+makeExample('cb-dependency-injection/ts/app/parent-finder.component.ts','cathy','parent-finder.component.ts (CathyComponent)')(format='.')
|
+makeExample('cb-dependency-injection/ts/app/parent-finder.component.ts','cathy','parent-finder.component.ts (CathyComponent)')(format='.')
|
||||||
:marked
|
:marked
|
||||||
We added the [@Optional](#optional) qualifier for safety but
|
We added the [@Optional](#optional) qualifier for safety but
|
||||||
the [live example](/resources/live-examples/cb-dependency-injection/ts/plnkr.html)
|
the <live-example name="cb-dependency-injection"></live-example>
|
||||||
confirms that the `alex` parameter is set.
|
confirms that the `alex` parameter is set.
|
||||||
|
|
||||||
<a id="base-parent"></a>
|
<a id="base-parent"></a>
|
||||||
@ -737,7 +737,7 @@ a(id='alex')
|
|||||||
+makeExample('cb-dependency-injection/ts/app/parent-finder.component.ts','craig','parent-finder.component.ts (CraigComponent)')(format='.')
|
+makeExample('cb-dependency-injection/ts/app/parent-finder.component.ts','craig','parent-finder.component.ts (CraigComponent)')(format='.')
|
||||||
:marked
|
:marked
|
||||||
Unfortunately, this does not work.
|
Unfortunately, this does not work.
|
||||||
The [live example](/resources/live-examples/cb-dependency-injection/ts/plnkr.html)
|
The <live-example name="cb-dependency-injection"></live-example>
|
||||||
confirms that the `alex` parameter is null.
|
confirms that the `alex` parameter is null.
|
||||||
*We cannot inject a parent by its base class.*
|
*We cannot inject a parent by its base class.*
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ include ../_util-fns
|
|||||||
[Dynamic Template](#dynamic-template)
|
[Dynamic Template](#dynamic-template)
|
||||||
|
|
||||||
:marked
|
:marked
|
||||||
**See the [live example](/resources/live-examples/cb-dynamic-form-deprecated/ts/plnkr.html)**.
|
**See the <live-example name="cb-dynamic-form-deprecated"></live-example>**.
|
||||||
|
|
||||||
.l-main-section
|
.l-main-section
|
||||||
<a id="object-model"></a>
|
<a id="object-model"></a>
|
||||||
|
@ -37,7 +37,7 @@ include ../_util-fns
|
|||||||
[Dynamic Template](#dynamic-template)
|
[Dynamic Template](#dynamic-template)
|
||||||
|
|
||||||
:marked
|
:marked
|
||||||
**See the [live example](/resources/live-examples/cb-dynamic-form/ts/plnkr.html)**.
|
**See the <live-example name="cb-dynamic-form"></live-example>**.
|
||||||
|
|
||||||
.l-main-section
|
.l-main-section
|
||||||
<a id="bootstrap"></a>
|
<a id="bootstrap"></a>
|
||||||
|
@ -5,7 +5,7 @@ a(id='top')
|
|||||||
Our app should be able to make the browser title bar say whatever we want it to say.
|
Our app should be able to make the browser title bar say whatever we want it to say.
|
||||||
This cookbook explains how to do it.
|
This cookbook explains how to do it.
|
||||||
:marked
|
:marked
|
||||||
**See the [live example](/resources/live-examples/cb-set-document-title/ts/plnkr.html)**.
|
**See the <live-example name="cb-set-document-title"></live-example>**.
|
||||||
.l-sub-section
|
.l-sub-section
|
||||||
img(src='/resources/images/devguide/plunker-separate-window-button.png' alt="pop out the window" align="right" style="margin-right:-20px")
|
img(src='/resources/images/devguide/plunker-separate-window-button.png' alt="pop out the window" align="right" style="margin-right:-20px")
|
||||||
:marked
|
:marked
|
||||||
|
@ -37,7 +37,7 @@ include ../_util-fns
|
|||||||
|
|
||||||
.l-sub-section
|
.l-sub-section
|
||||||
:marked
|
:marked
|
||||||
The examples referenced in this chapter are available as a [live example](/resources/live-examples/animations/ts/plnkr.html).
|
The examples referenced in this chapter are available as a <live-example></live-example>.
|
||||||
|
|
||||||
a(id="example-transitioning-between-states")
|
a(id="example-transitioning-between-states")
|
||||||
.l-main-section
|
.l-main-section
|
||||||
|
@ -35,7 +35,7 @@ include ../_util-fns
|
|||||||
|
|
||||||
- sharing information among controls with template reference variables
|
- sharing information among controls with template reference variables
|
||||||
|
|
||||||
[Live Example](/resources/live-examples/forms-deprecated/ts/plnkr.html)
|
<live-example>Live Example</live-example>
|
||||||
.l-main-section
|
.l-main-section
|
||||||
:marked
|
:marked
|
||||||
## Template-Driven Forms
|
## Template-Driven Forms
|
||||||
|
@ -37,7 +37,7 @@ include ../_util-fns
|
|||||||
|
|
||||||
- sharing information among controls with template reference variables
|
- sharing information among controls with template reference variables
|
||||||
|
|
||||||
[Live Example](/resources/live-examples/forms/ts/plnkr.html)
|
<live-example>Live Example</live-example>
|
||||||
|
|
||||||
.l-main-section
|
.l-main-section
|
||||||
:marked
|
:marked
|
||||||
|
@ -100,7 +100,7 @@ table(width="100%")
|
|||||||
block example-links
|
block example-links
|
||||||
:marked
|
:marked
|
||||||
Look for a link to a running version of that sample near the top of each page,
|
Look for a link to a running version of that sample near the top of each page,
|
||||||
such as this [live example](/resources/live-examples/architecture/ts/plnkr.html) from the [Architecture](architecture.html) chapter.
|
such as this <live-example></live-example> from the [Architecture](architecture.html) chapter.
|
||||||
|
|
||||||
The link launches a browser-based code editor where we can inspect, modify, save, and download the code.
|
The link launches a browser-based code editor where we can inspect, modify, save, and download the code.
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ include ../_util-fns
|
|||||||
as users perform application tasks.
|
as users perform application tasks.
|
||||||
|
|
||||||
We cover the router's primary features in this chapter, illustrating them through the evolution
|
We cover the router's primary features in this chapter, illustrating them through the evolution
|
||||||
of a small application that we can [run live](/resources/live-examples/router-deprecated/ts/plnkr.html).
|
of a small application that we can <live-example>run live</live-example>.
|
||||||
.l-sub-section
|
.l-sub-section
|
||||||
img(src='/resources/images/devguide/plunker-separate-window-button.png' alt="pop out the window" align="right" style="margin-right:-20px")
|
img(src='/resources/images/devguide/plunker-separate-window-button.png' alt="pop out the window" align="right" style="margin-right:-20px")
|
||||||
:marked
|
:marked
|
||||||
@ -207,7 +207,7 @@ table
|
|||||||
We discuss code and design decisions pertinent to routing and application design.
|
We discuss code and design decisions pertinent to routing and application design.
|
||||||
We gloss over everything in between.
|
We gloss over everything in between.
|
||||||
|
|
||||||
The full source is available in the [live example](/resources/live-examples/router-deprecated/ts/plnkr.html).
|
The full source is available in the <live-example></live-example>
|
||||||
:marked
|
:marked
|
||||||
Our client is the Hero Employment Agency.
|
Our client is the Hero Employment Agency.
|
||||||
Heroes need work and The Agency finds Crises for them to solve.
|
Heroes need work and The Agency finds Crises for them to solve.
|
||||||
@ -216,7 +216,7 @@ table
|
|||||||
1. A *Crisis Center* where we maintain the list of crises for assignment to heroes.
|
1. A *Crisis Center* where we maintain the list of crises for assignment to heroes.
|
||||||
1. A *Heroes* area where we maintain the list of heroes employed by The Agency.
|
1. A *Heroes* area where we maintain the list of heroes employed by The Agency.
|
||||||
|
|
||||||
Run the [live example](/resources/live-examples/router-deprecated/ts/plnkr.html).
|
Run the <live-example></live-example>.
|
||||||
It opens in the *Crisis Center*. We'll come back to that.
|
It opens in the *Crisis Center*. We'll come back to that.
|
||||||
|
|
||||||
Click the *Heroes* link. We're presented with a list of Heroes.
|
Click the *Heroes* link. We're presented with a list of Heroes.
|
||||||
@ -1110,7 +1110,7 @@ code-example(format="." language="bash").
|
|||||||
|
|
||||||
.l-sub-section
|
.l-sub-section
|
||||||
:marked
|
:marked
|
||||||
The [live example](/resources/live-examples/router-deprecated/ts/plnkr.html) *does* highlight the selected
|
The <live-example></live-example> *does* highlight the selected
|
||||||
row because it demonstrates the final state of the application which includes the steps we're *about* to cover.
|
row because it demonstrates the final state of the application which includes the steps we're *about* to cover.
|
||||||
At the moment we're describing the state of affairs *prior* to those steps.
|
At the moment we're describing the state of affairs *prior* to those steps.
|
||||||
:marked
|
:marked
|
||||||
@ -1202,7 +1202,7 @@ code-example(format="." language="bash").
|
|||||||
As we end our chapter, we take a parting look at
|
As we end our chapter, we take a parting look at
|
||||||
the entire application.
|
the entire application.
|
||||||
|
|
||||||
We can always try the [live example](/resources/live-examples/router-deprecated/ts/plnkr.html) and download the source code from there.
|
We can always try the <live-example></live-example> and download the source code from there.
|
||||||
|
|
||||||
Our final project folder structure looks like this:
|
Our final project folder structure looks like this:
|
||||||
.filetree
|
.filetree
|
||||||
|
@ -10,7 +10,7 @@ include ../_util-fns
|
|||||||
as users perform application tasks.
|
as users perform application tasks.
|
||||||
|
|
||||||
We cover the router's primary features in this chapter, illustrating them through the evolution
|
We cover the router's primary features in this chapter, illustrating them through the evolution
|
||||||
of a small application that we can [run live](/resources/live-examples/router/ts/plnkr.html).
|
of a small application that we can <live-example>run live</live-example>.
|
||||||
.l-sub-section
|
.l-sub-section
|
||||||
img(src='/resources/images/devguide/plunker-separate-window-button.png' alt="pop out the window" align="right" style="margin-right:-20px")
|
img(src='/resources/images/devguide/plunker-separate-window-button.png' alt="pop out the window" align="right" style="margin-right:-20px")
|
||||||
:marked
|
:marked
|
||||||
@ -250,7 +250,7 @@ table
|
|||||||
We discuss code and design decisions pertinent to routing and application design.
|
We discuss code and design decisions pertinent to routing and application design.
|
||||||
We gloss over everything in between.
|
We gloss over everything in between.
|
||||||
|
|
||||||
The full source is available in the [live example](/resources/live-examples/router/ts/plnkr.html).
|
The full source is available in the <live-example></live-example>.
|
||||||
:marked
|
:marked
|
||||||
Our client is the Hero Employment Agency.
|
Our client is the Hero Employment Agency.
|
||||||
Heroes need work and The Agency finds Crises for them to solve.
|
Heroes need work and The Agency finds Crises for them to solve.
|
||||||
@ -259,7 +259,7 @@ table
|
|||||||
1. A *Crisis Center* where we maintain the list of crises for assignment to heroes.
|
1. A *Crisis Center* where we maintain the list of crises for assignment to heroes.
|
||||||
1. A *Heroes* area where we maintain the list of heroes employed by The Agency.
|
1. A *Heroes* area where we maintain the list of heroes employed by The Agency.
|
||||||
|
|
||||||
Run the [live example](/resources/live-examples/router/ts/plnkr.html).
|
Run the <live-example></live-example>.
|
||||||
It opens in the *Crisis Center*. We'll come back to that.
|
It opens in the *Crisis Center*. We'll come back to that.
|
||||||
|
|
||||||
Click the *Heroes* link. We're presented with a list of Heroes.
|
Click the *Heroes* link. We're presented with a list of Heroes.
|
||||||
@ -1442,7 +1442,7 @@ code-example(format="." language="bash").
|
|||||||
|
|
||||||
.l-sub-section
|
.l-sub-section
|
||||||
:marked
|
:marked
|
||||||
The [live example](/resources/live-examples/router/ts/plnkr.html) *does* highlight the selected
|
The <live-example></live-example> *does* highlight the selected
|
||||||
row because it demonstrates the final state of the application which includes the steps we're *about* to cover.
|
row because it demonstrates the final state of the application which includes the steps we're *about* to cover.
|
||||||
At the moment we're describing the state of affairs *prior* to those steps.
|
At the moment we're describing the state of affairs *prior* to those steps.
|
||||||
:marked
|
:marked
|
||||||
@ -1529,7 +1529,7 @@ figure.image-display
|
|||||||
:marked
|
:marked
|
||||||
## Wrap Up
|
## Wrap Up
|
||||||
We've covered a lot of ground in this chapter and the application is too big to reprint here.
|
We've covered a lot of ground in this chapter and the application is too big to reprint here.
|
||||||
Please visit the [live example](/resources/live-examples/router/ts/plnkr.html) and
|
Please visit the <live-example></live-example> and
|
||||||
where you can download the final source code.
|
where you can download the final source code.
|
||||||
|
|
||||||
.l-main-section
|
.l-main-section
|
||||||
|
@ -6,7 +6,7 @@ include ../_util-fns
|
|||||||
In this chapter we learn to bind to those events using the Angular
|
In this chapter we learn to bind to those events using the Angular
|
||||||
event binding syntax.
|
event binding syntax.
|
||||||
|
|
||||||
[Run the live example](/resources/live-examples/user-input/ts/plnkr.html)
|
<live-example>Run the live example</live-example>
|
||||||
|
|
||||||
:marked
|
:marked
|
||||||
## Binding to user input events
|
## Binding to user input events
|
||||||
|
@ -17,7 +17,7 @@ angularIO.directive('ifDocs', ['ngIfDirective', '$location', function (ngIfDirec
|
|||||||
terminal: ngIf.terminal,
|
terminal: ngIf.terminal,
|
||||||
restrict: ngIf.restrict,
|
restrict: ngIf.restrict,
|
||||||
link: function (scope, element, attrs) {
|
link: function (scope, element, attrs) {
|
||||||
var ngIfCond = (attrs.ifDocs === 'dart') == !NgIoUtil.isDartDoc($location);
|
var ngIfCond = (attrs.ifDocs === 'dart') == !NgIoUtil.isDoc($location, 'dart');
|
||||||
attrs.ngIf = function () { return !ngIfCond; }
|
attrs.ngIf = function () { return !ngIfCond; }
|
||||||
ngIf.link.apply(ngIf, arguments);
|
ngIf.link.apply(ngIf, arguments);
|
||||||
}
|
}
|
||||||
|
@ -28,10 +28,12 @@ angularIO.directive('liveExample', ['$location', function ($location) {
|
|||||||
var ex = attrs.name || NgIoUtil.getExampleName($location);
|
var ex = attrs.name || NgIoUtil.getExampleName($location);
|
||||||
var href, template;
|
var href, template;
|
||||||
|
|
||||||
var isForDart = attrs.lang === 'dart' || NgIoUtil.isDartDoc($location);
|
var isForDart = attrs.lang === 'dart' || NgIoUtil.isDoc($location, 'dart');
|
||||||
|
var isForJs = attrs.lang === 'js' || NgIoUtil.isDoc($location, 'js');
|
||||||
|
var exLang = isForDart ? 'dart' : isForJs ? 'js' : 'ts';
|
||||||
var href = isForDart
|
var href = isForDart
|
||||||
? 'http://angular-examples.github.io/' + ex
|
? 'http://angular-examples.github.io/' + ex
|
||||||
: '/resources/live-examples/' + ex + '/ts/plnkr.html';
|
: '/resources/live-examples/' + ex + '/' + exLang + '/plnkr.html';
|
||||||
|
|
||||||
// Link to live example.
|
// Link to live example.
|
||||||
var template = a(text, { href: href, target: '_blank' });
|
var template = a(text, { href: href, target: '_blank' });
|
||||||
|
@ -23,7 +23,7 @@ angularIO.directive('ngioEx', ['$location', function ($location) {
|
|||||||
|
|
||||||
compile: function (tElement, attrs) {
|
compile: function (tElement, attrs) {
|
||||||
var examplePath = attrs.path || tElement.text();
|
var examplePath = attrs.path || tElement.text();
|
||||||
if (NgIoUtil.isDartDoc($location) || attrs.lang === 'dart') {
|
if (NgIoUtil.isDoc($location, 'dart') || attrs.lang === 'dart') {
|
||||||
examplePath = NgIoUtil.adjustTsExamplePathForDart(examplePath);
|
examplePath = NgIoUtil.adjustTsExamplePathForDart(examplePath);
|
||||||
}
|
}
|
||||||
var template = '<code>' + examplePath + '</code>';
|
var template = '<code>' + examplePath + '</code>';
|
||||||
|
@ -4,9 +4,9 @@ var NgIoUtil = (function () {
|
|||||||
|
|
||||||
function NgIoUtil() { }
|
function NgIoUtil() { }
|
||||||
|
|
||||||
NgIoUtil.isDartDoc = function ($location) {
|
NgIoUtil.isDoc = function ($location, lang) {
|
||||||
var loc = $location.absUrl();
|
var loc = $location.absUrl();
|
||||||
return loc.includes('/docs/dart/');
|
return loc.includes('/docs/' + lang + '/');
|
||||||
};
|
};
|
||||||
|
|
||||||
// The following util functions are adapted from _utils-fn.jade.
|
// The following util functions are adapted from _utils-fn.jade.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user