@@ -556,7 +556,7 @@ export class Component extends Directive {
556556}
557557
558558/**
559- * A directive used for dynamically loading components.
559+ * Directive used for dynamically loading components.
560560 *
561561 * Regular angular components are statically resolved. DynamicComponent allows to you resolve a component at runtime
562562 * instead by providing a placeholder into which a regular angular component can be dynamically loaded. Once loaded,
@@ -637,9 +637,9 @@ export class DynamicComponent extends Directive {
637637/**
638638 * Directive that attaches behavior to DOM elements.
639639 *
640- * A decorator directive attaches behavior to a DOM element in a composable manner.
640+ * A decorator directive attaches behavior to a DOM element in a composable manner.
641641 * (see: http://en.wikipedia.org/wiki/Composition_over_inheritance)
642- *
642+ *
643643 * Decorators:
644644 * - are simplest form of [Directive]s.
645645 * - are best used as a composition pattern ()
@@ -652,7 +652,7 @@ export class DynamicComponent extends Directive {
652652 *
653653 * ## Example
654654 *
655- * Here we use a decorator directive to simply define basic tool-tip behavior.
655+ * Here we use a decorator directive to simply define basic tool-tip behavior.
656656 *
657657 * ```
658658 * @Decorator ({
@@ -685,9 +685,9 @@ export class DynamicComponent extends Directive {
685685 * }
686686 * }
687687 * ```
688- * In our HTML template, we can then add this behavior to a `<div>` or any other element with the `tooltip` selector,
688+ * In our HTML template, we can then add this behavior to a `<div>` or any other element with the `tooltip` selector,
689689 * like so:
690- *
690+ *
691691 * ```
692692 * <div tooltip="some text here"></div>
693693 * ```
@@ -728,24 +728,45 @@ export class Decorator extends Directive {
728728}
729729
730730/**
731- * Viewport is used for controlling the instatiation of inline templates. [TODO: needs co-work :)]
731+ * Directive that controls the instantiation, destruction, and positioning of inline template elements.
732732 *
733- * Viewport consist of a controller which can inject [ViewContainer]. A [ViewContainer] represents a location in the
734- * current view where child views can be inserted. [ViewContainer] is created as a result of `<template>` element.
733+ * A viewport directive uses a [ViewContainer] to instantiate, insert, move, and destroy views at runtime.
734+ * The [ViewContainer] is created as a result of `<template>` element, and represents a location in the current view
735+ * where these actions are performed.
735736 *
736- * NOTE: `<template>` directives can be created in shorthand form as `<TAG template="...">` or `<TAG *key="...">`
737+ * Views are always created as children of the current [View], and as siblings of the `<template>` element. Thus a
738+ * directive in a child view cannot inject the viewport directive that created it.
737739 *
738- * ## Example
740+ * Since viewport directives are common in Angular, and using the full `<template>` element syntax is wordy, Angular
741+ * also supports a shorthand notation: `<li *foo="bar">` and `<li template="foo: bar">` are equivalent.
739742 *
740- * Given folowing inline template, let's implement the `unless` behavior.
743+ * Thus,
741744 *
742745 * ```
743746 * <ul>
744- * <li *unless="expr"></li>
747+ * <li *foo="bar" title="text"></li>
748+ * </ul>
749+ * ```
750+ *
751+ * Expands in use to:
752+ *
753+ * ```
754+ * <ul>
755+ * <template [foo]="bar">
756+ * <li title="text"></li>
757+ * </template>
745758 * </ul>
746759 * ```
747760 *
748- * Can be implemented using:
761+ * Notice that although the shorthand places `*foo="bar"` within the `<li>` element, the binding for the `Viewport`
762+ * controller is correctly instantiated on the `<template>` element rather than the `<li>` element.
763+ *
764+ *
765+ * ## Example
766+ *
767+ * Let's suppose we want to implement the `unless` behavior, to conditionally include a template.
768+ *
769+ * Here is a simple viewport directive that triggers on an `unless` selector:
749770 *
750771 * ```
751772 * @Viewport ({
@@ -754,7 +775,7 @@ export class Decorator extends Directive {
754775 * 'condition': 'unless'
755776 * }
756777 * })
757- * export class If {
778+ * export class Unless {
758779 * viewContainer: ViewContainer;
759780 * prevCondition: boolean;
760781 *
@@ -775,20 +796,14 @@ export class Decorator extends Directive {
775796 * }
776797 * ```
777798 *
778- * To better undarstand what is hapening, remember that angular converts the above template to:
779- *
799+ * We can then use this `unless` selector in a template:
780800 * ```
781801 * <ul>
782- * <template [unless]="exp">
783- * <li></li>
784- * </template>
802+ * <li *unless="expr"></li>
785803 * </ul>
786804 * ```
787805 *
788- * Notice that the `*unless="exp"` got hoisted to `<template>`. This means that the `Viewport` controller is instantiated
789- * on the `<template>` element rather thna the `<li>` element.
790- *
791- * Once the viewport insntantiates the child view the result is:
806+ * Once the viewport instantiates the child view, the shorthand notation for the template expands and the result is:
792807 *
793808 * ```
794809 * <ul>
@@ -799,9 +814,8 @@ export class Decorator extends Directive {
799814 * </ul>
800815 * ```
801816 *
802- * The key thing to notice here is that `<li>` instance is a sibling of `<template>` not a child. For this reason
803- * it is not possible to inject `Viewport` directive into other directives, (`Viweport` directives are always on
804- * `<template>` elements which are leafs.)
817+ * Note also that although the `<li></li>` template still exists inside the `<template></template>`, the instantiated
818+ * view occurs on the second `<li></li>` which is a sibling to the `<template>` element.
805819 *
806820 *
807821 * @publicModule angular2/annotations
@@ -831,7 +845,7 @@ export class Viewport extends Directive {
831845//TODO(misko): turn into LifecycleEvent class once we switch to TypeScript;
832846
833847/**
834- * Specify that a directive should be notified whenever a [View] that contains it is destroyed.
848+ * Notify a directive whenever a [View] that contains it is destroyed.
835849 *
836850 * ## Example
837851 *
@@ -852,7 +866,7 @@ export const onDestroy = "onDestroy";
852866
853867
854868/**
855- * Specify that a directive should be notified when any of its bindings have changed.
869+ * Notify a directive when any of its bindings have changed.
856870 *
857871 * ## Example:
858872 *
0 commit comments