+
+
+ Loading app...
+
+
+
+
diff --git a/public/docs/_examples/cb-item-template/ts/plnkr.json b/public/docs/_examples/cb-item-template/ts/plnkr.json
new file mode 100644
index 0000000000..0131610c20
--- /dev/null
+++ b/public/docs/_examples/cb-item-template/ts/plnkr.json
@@ -0,0 +1,9 @@
+{
+ "description": "Set The Document Title In Angular 2",
+ "files": [
+ "!**/*.d.ts",
+ "!**/*.js",
+ "!**/*.[1].*"
+ ],
+ "tags": [ "cookbook" ]
+}
diff --git a/public/docs/_examples/cb-item-template/ts/sample.css b/public/docs/_examples/cb-item-template/ts/sample.css
new file mode 100644
index 0000000000..927345d292
--- /dev/null
+++ b/public/docs/_examples/cb-item-template/ts/sample.css
@@ -0,0 +1,65 @@
+a {
+ color: #607D8B ;
+ text-decoration: underline ;
+}
+
+simple-select {
+ cursor: pointer ;
+ display: 'inline-block' ;
+ font-size: 16px ;
+ position: relative ;
+ user-select: none ;
+ -moz-user-select: none ;
+ -webkit-user-select: none ;
+}
+
+simple-select button.select-root {
+ background-color: #FFFFFF ;
+ border: 1px solid #CCCCCC ;
+ border-radius: 3px 3px 3px 3px ;
+ color: #333333 ;
+ font-size: inherit ;
+ padding: 7px 10px 7px 10px ;
+ position: relative ;
+}
+
+simple-select ul.select-items {
+ background-color: #FFFFFF ;
+ border: 1px solid #CCCCCC ;
+ border-radius: 3px 3px 3px 3px ;
+ left: 0px ;
+ list-style-type: none ;
+ margin: 0px 0px 0px 0px ;
+ padding: 0px 0px 0px 0px ;
+ position: absolute ;
+ top: 102% ;
+ white-space: nowrap ;
+ z-index: 2 ;
+}
+
+simple-select ul.select-items li {
+ border-top: 1px solid #CCCCCC ;
+ margin: 0px 0px 0px 0px ;
+ padding: 7px 10px 7px 10px ;
+ position: relative ;
+}
+
+simple-select ul.select-items li:first-child {
+ border-top-width: 0px ;
+}
+
+/* Custom template styles. */
+
+simple-select {
+ display: table ;
+ margin: 16px 0px 16px 0px ;
+}
+
+simple-select span.swatch {
+ border: 1px solid #CCCCCC ;
+ border-radius: 3px 3px 3px 3px ;
+ display: inline-block ;
+ height: 13px ;
+ margin: 2px 5px 0px 0px ;
+ width: 13px ;
+}
\ No newline at end of file
diff --git a/public/docs/ts/latest/cookbook/_data.json b/public/docs/ts/latest/cookbook/_data.json
index f82d816cef..e8ac3da01b 100644
--- a/public/docs/ts/latest/cookbook/_data.json
+++ b/public/docs/ts/latest/cookbook/_data.json
@@ -43,6 +43,11 @@
"intro": "Render dynamic forms with FormGroup"
},
+ "item-template": {
+ "title": "Item Template",
+ "intro": "Providing a component with an item template for dynamic rendering."
+ },
+
"rc4-to-rc5": {
"title": "RC4 to RC5 Migration",
"intro": "Migrate your RC4 app to RC5 in minutes."
diff --git a/public/docs/ts/latest/cookbook/item-template.jade b/public/docs/ts/latest/cookbook/item-template.jade
new file mode 100644
index 0000000000..499002d43b
--- /dev/null
+++ b/public/docs/ts/latest/cookbook/item-template.jade
@@ -0,0 +1,98 @@
+include ../_util-fns
+
+a( id='top' )
+:marked
+ If a component needs to render a collection of items, we can keep the component generic
+ by providing the component with a `TemplateRef` that the component can use to render
+ the individual items. This way, the component's scope of responsibility is limited
+ while its reusability is enhanced. The `TemplateRef` can be explicitly injected into
+ the component as an input property; or, the `TemplateRef` can be implicitly provided as
+ part of the component's content.
+
+:marked
+ To explore this concept, we'll create a simple Select menu component that takes an
+ `items` input collection and uses an externally-provided `TemplateRef` to render each
+ item in the menu options list. Then, we'll instantiate the Select menu component twice
+ in order to demonstrate the various ways in which we can provide the `TemplateRef`.
+
+:marked
+ In the following root-component meta-data, each Select menu (selector: `simple-select`)
+ is rendering the same collection of color `items`; and, each select menu is binding to
+ the same `value`. The only difference between the two instances is in how the
+ `TemplateRef` is being defined:
+
+:marked
+ **See the [live example](/resources/live-examples/cb-item-template/ts/plnkr.html)**.
+
++makeExample('cb-item-template/ts/app/app.component.ts', 'metadata', 'app/app.component.ts (metadata)')(format='.')
+
+:marked
+ In the first ``, the `TemplateRef` is being defined as a child of the
+ `` element. In the second ``, the `TemplateRef` is being
+ defined as a sibling element and is then being passed-in as the `[template]` property.
+
+.l-sub-section
+ :marked
+ There's no requirement that a component must accept a `TemplateRef` from multiple
+ sources. It does make the component more flexible; but, we're only doing it for
+ demonstrative purposes in this cookbook.
+
+:marked
+ Since the component is capable of accepting a `TemplateRef` by two different means,
+ we're going to define two setter methods — one for the `[template]` input and one
+ for the content query — that coalesce the two sources into a single `TemplateRef`
+ property.
+
++makeExample('cb-item-template/ts/app/simple-select.component.ts', 'setters', 'app/simple-select.component.ts (TemplateRef setters')(format='.')
+
+:marked
+ Once the two `TemplateRef` sources have been coalesced into a single `itemTemplateRef`
+ property, we can then use it to render both the menu items and the menu root.
+
++makeExample('cb-item-template/ts/app/simple-select.component.ts', 'metadata', 'app/simple-select.component.ts (metadata')(format='.')
+
+:marked
+ When we use the `` directive to render our externally-provided `TemplateRef`,
+ we supply both the `[ngTemplateOutlet]` and the `[ngOutletContext]` property. The
+ former is the template reference; the latter is the collection of local variables that
+ can be accessed in the calling context. For example, since our "context" object
+ includes a property named `item`, our root component can access this property in its
+ `` element via `let`:
+
+code-example(format='')
+ <template let-item='item'> ... </template>
+
+:marked
+ Bringing it all together, we now have a component that can accept an externally-
+ provided `TemplateRef` and use it to render multiple aspects of its own internal
+ component template.
+
+figure.image-display
+ img(src='/resources/images/cookbooks/item-template/item-template-animation.gif' alt='Item Template')
+
+:marked
+ The complete code:
+
++makeTabs(
+ `
+ cb-item-template/ts/app/main.ts,
+ cb-item-template/ts/app/app.component.ts,
+ cb-item-template/ts/app/simple-select.component.ts
+ `,
+ '',
+ `
+ app/main.ts,
+ app/app.component.ts,
+ app/simple-select.component.ts
+ `
+)
+
+.l-sub-section
+ :marked
+ **Did you know:** The `ngFor` directive can accept an externally-provided
+ `TemplateRef` which can be used to render the items in the `[ngForOf]` collection:
+
+ ``
+
+:marked
+ [Back to top](#top)
diff --git a/public/resources/images/cookbooks/item-template/item-template-animation.gif b/public/resources/images/cookbooks/item-template/item-template-animation.gif
new file mode 100644
index 0000000000..ae79c7a325
Binary files /dev/null and b/public/resources/images/cookbooks/item-template/item-template-animation.gif differ