+ `,
+ directives: [CORE_DIRECTIVES]
+})
+class LittleTour {
+ heroes=['Windstorm', 'Bombasto', 'Magneta', 'Tornado'];
+
+ addHero(newHero) {
+ if (newHero.value) {
+ this.heroes.push(newHero.value);
+ newHero.value = null; // clear the newHero textbox
+ }
+ }
+}
+
+bootstrap(LittleTour);
+// #enddocregion little-tour-of-heroes-app
diff --git a/public/docs/_examples/user-input/ts/src/index.html b/public/docs/_examples/user-input/ts/src/index.html
new file mode 100644
index 0000000000..d59ff63b82
--- /dev/null
+++ b/public/docs/_examples/user-input/ts/src/index.html
@@ -0,0 +1,22 @@
+
+
+
+ User Input
+
+
+
+
+
+
+
+ Loading...
+
+ Loading...
+
+
+
\ No newline at end of file
diff --git a/public/docs/_examples/user-input/ts/src/styles.css b/public/docs/_examples/user-input/ts/src/styles.css
new file mode 100644
index 0000000000..b2133e5103
--- /dev/null
+++ b/public/docs/_examples/user-input/ts/src/styles.css
@@ -0,0 +1,9 @@
+fieldset {border-style:none}
+img {height: 100px;}
+.box {border: 1px solid black; padding:3px}
+.child-div {margin-left: 1em; font-weight: normal}
+.hidden {display: none}
+.parent-div {margin-top: 1em; font-weight: bold}
+.special {font-weight:bold;}
+.toe {margin-left: 1em; font-style: italic;}
+little-hero {color:blue; font-size: smaller; background-color: Turquoise }
\ No newline at end of file
diff --git a/public/docs/_examples/user-input/ts/src/tsconfig.json b/public/docs/_examples/user-input/ts/src/tsconfig.json
new file mode 100644
index 0000000000..6a58b35a58
--- /dev/null
+++ b/public/docs/_examples/user-input/ts/src/tsconfig.json
@@ -0,0 +1,11 @@
+{
+ "compilerOptions": {
+ "target": "ES5",
+ "module": "commonjs",
+ "sourceMap": true,
+ "emitDecoratorMetadata": true,
+ "experimentalDecorators": true,
+ "removeComments": false,
+ "noImplicitAny": false
+ }
+}
\ No newline at end of file
diff --git a/public/docs/ts/latest/guide/user-input.jade b/public/docs/ts/latest/guide/user-input.jade
index 4225fc7d2f..b739e216b2 100644
--- a/public/docs/ts/latest/guide/user-input.jade
+++ b/public/docs/ts/latest/guide/user-input.jade
@@ -13,7 +13,7 @@ include ../../../../_includes/_util-fns
The syntax is simple. We assign a template expression to the DOM event name, surrounded in parentheses.
A click Event Binding makes for a quick illustration.
-+makeExample('template-syntax/ts/src/app/app.html', 'click-me-button')(format=".")
++makeExample('user-input/ts/src/app/app.html', 'click-me-button')(format=".")
:markdown
The `(click)` to the left of the equal sign identifies the button's click event as the **target of the binding**.
@@ -28,7 +28,7 @@ include ../../../../_includes/_util-fns
-+makeExample('template-syntax/ts/src/app/app.ts', 'click-me-component')
++makeExample('user-input/ts/src/app/app.ts', 'click-me-component')
:markdown
The `onClickMe` in the template refers to the `onClickMe` method of the component.
When the user clicks the button, Angular calls the component's `onClickMe` method.
@@ -40,7 +40,7 @@ include ../../../../_includes/_util-fns
what the user types back onto the screen.
This time we'll both listen to an event and grab the user's input.
-+makeExample('template-syntax/ts/src/app/app.ts', 'key-up-component')
++makeExample('user-input/ts/src/app/app.ts', 'key-up-component')
:markdown
Angular makes an event object available in the **`$event`** variable. The user data we want is in that variable somewhere.
@@ -72,7 +72,7 @@ code-example().
Let's demonstrate with a clever keystroke loopback in a single line of template HTML.
We don't actually need a dedicated component to do this but we'll make one anyway.
-+makeExample('template-syntax/ts/src/app/app.ts', 'loop-back-component')
++makeExample('user-input/ts/src/app/app.ts', 'loop-back-component')
:markdown
We've declared a template local variable named `box` on the `` element.
The `box` variable is a reference to the `` element itself which means we can
@@ -91,7 +91,7 @@ code-example().
That local template variable is intriguing. It's clearly easer to get to the textbox with that
variable than to go through the `$event` object. Maybe we can re-write our previous
"key-up" example using the variable to acquire the user's' input. Let's give it a try.
-+makeExample('template-syntax/ts/src/app/app.ts', 'key-up2-component')
++makeExample('user-input/ts/src/app/app.ts', 'key-up2-component')
:markdown
That sure seems easier.
An especially nice aspect of this approach is that our component code gets clean data values from the view.
@@ -112,12 +112,20 @@ code-example().
Only then do we update the component's `values` property ...
inside the event expression rather than in the component ...
because we can ... even if it is a dubious practice.
-+makeExample('template-syntax/ts/src/app/app.ts', 'key-up3-component')
-.alert.is-helpful
- :markdown
- We won't transfer the current state of the input box if the user mouses away or clicks
- elsewhere on the page. We only update the component's `values` property when the user presses "Enter"
- inside the input box.
++makeExample('user-input/ts/src/app/app.ts', 'key-up3-component')
+
+.l-main-section
+:markdown
+ ## On blur
+
+ Our previous example won't transfer the current state of the input box if the user mouses away and clicks
+ elsewhere on the page. We only update the component's `values` property when the user presses "Enter"
+ inside the input box.
+
+ Let's fix that by listening to the input box's blur event as well.
+
++makeExample('user-input/ts/src/app/app.ts', 'key-up4-component')
+
.l-main-section
:markdown
## Put it all together
@@ -125,7 +133,9 @@ code-example().
We've acquired a small arsenal of event binding techniques in this chapter.
Let's put it all together in a micro-app
- that can display a list of heroes and add new heroes to that list.
+ that can display a list of heroes and add new heroes to that list
+ by typing in the input box and hitting "Enter", clicking "Add", or clicking
+ elsewhere on the page.
figure.image-display
img(src='/resources/images/devguide/user-input/little-tour.png' alt="Little Tour of Heroes")
@@ -135,7 +145,7 @@ figure.image-display
-+makeExample('template-syntax/ts/src/app/app.ts', 'little-tour-of-heroes-app')
++makeExample('user-input/ts/src/app/app.ts', 'little-tour-of-heroes-app')
:markdown
We've seen almost everything here before. A few things are new or bear repeating.
@@ -148,11 +158,6 @@ figure.image-display
The Angular workaround is to spell the declaration in "snake case". Angular translates "#new-hero"
to `newHero` for template expressions ... which is exactly what we want.
-
- ### **keyup.enter filter**
- We'll add a hero when the user clicks the "Add" button or hits the "Enter" key. We ignore all other keys.
- We accept that we might lose the new hero if the user clicks elsewhere or leaves the page
- without having hit "Enter" or the "Add" button first. Let's hope the users don't complain.
### **newHero refers to the `` element**
We can access the `newHero` variable from any sibling or child of the `` element.
diff --git a/public/resources/images/devguide/user-input/little-tour.png b/public/resources/images/devguide/user-input/little-tour.png
index 5758505843..40389d1a20 100644
Binary files a/public/resources/images/devguide/user-input/little-tour.png and b/public/resources/images/devguide/user-input/little-tour.png differ