433 lines
11 KiB
HTML
433 lines
11 KiB
HTML
<html lang="en"><head></head><body><form id="mainForm" method="post" action="http://plnkr.co/edit/?p=preview" target="_self"><input type="hidden" name="files[app/app.component.ts]" value="import { Component } from '@angular/core';
|
|
|
|
@Component({
|
|
moduleId: module.id,
|
|
selector: 'my-app',
|
|
templateUrl: './app.component.html'
|
|
})
|
|
export class AppComponent { }
|
|
|
|
|
|
/*
|
|
Copyright 2016 Google Inc. All Rights Reserved.
|
|
Use of this source code is governed by an MIT-style license that
|
|
can be found in the LICENSE file at http://angular.io/license
|
|
*/"><input type="hidden" name="files[app/app.module.ts]" value="import { NgModule } from '@angular/core';
|
|
import { BrowserModule } from '@angular/platform-browser';
|
|
|
|
import { AppComponent } from './app.component';
|
|
import { ClickMeComponent } from './click-me.component';
|
|
import { ClickMe2Component } from './click-me2.component';
|
|
import {
|
|
KeyUpComponent_v1,
|
|
KeyUpComponent_v2,
|
|
KeyUpComponent_v3,
|
|
KeyUpComponent_v4
|
|
} from './keyup.components';
|
|
import { LittleTourComponent } from './little-tour.component';
|
|
import { LoopbackComponent } from './loop-back.component';
|
|
|
|
|
|
@NgModule({
|
|
imports: [
|
|
BrowserModule
|
|
],
|
|
declarations: [
|
|
AppComponent,
|
|
ClickMeComponent,
|
|
ClickMe2Component,
|
|
KeyUpComponent_v1,
|
|
KeyUpComponent_v2,
|
|
KeyUpComponent_v3,
|
|
KeyUpComponent_v4,
|
|
LittleTourComponent,
|
|
LoopbackComponent
|
|
],
|
|
providers: [
|
|
|
|
],
|
|
bootstrap: [ AppComponent ]
|
|
})
|
|
export class AppModule { }
|
|
|
|
|
|
/*
|
|
Copyright 2016 Google Inc. All Rights Reserved.
|
|
Use of this source code is governed by an MIT-style license that
|
|
can be found in the LICENSE file at http://angular.io/license
|
|
*/"><input type="hidden" name="files[app/click-me.component.ts]" value="/* FOR DOCS ... MUST MATCH ClickMeComponent template
|
|
<button (click)="onClickMe()">Click me!</button>
|
|
*/
|
|
|
|
import { Component } from '@angular/core';
|
|
|
|
@Component({
|
|
selector: 'click-me',
|
|
template: `
|
|
<button (click)="onClickMe()">Click me!</button>
|
|
{{clickMessage}}`
|
|
})
|
|
export class ClickMeComponent {
|
|
clickMessage = '';
|
|
|
|
onClickMe() {
|
|
this.clickMessage = 'You are my hero!';
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
Copyright 2016 Google Inc. All Rights Reserved.
|
|
Use of this source code is governed by an MIT-style license that
|
|
can be found in the LICENSE file at http://angular.io/license
|
|
*/"><input type="hidden" name="files[app/click-me2.component.ts]" value="import { Component } from '@angular/core';
|
|
|
|
@Component({
|
|
selector: 'click-me2',
|
|
template: `
|
|
<button (click)="onClickMe2($event)">No! .. Click me!</button>
|
|
{{clickMessage}}`
|
|
})
|
|
export class ClickMe2Component {
|
|
clickMessage = '';
|
|
clicks = 1;
|
|
|
|
onClickMe2(event: any) {
|
|
let evtMsg = event ? ' Event target is ' + event.target.tagName : '';
|
|
this.clickMessage = (`Click #${this.clicks++}. ${evtMsg}`);
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
Copyright 2016 Google Inc. All Rights Reserved.
|
|
Use of this source code is governed by an MIT-style license that
|
|
can be found in the LICENSE file at http://angular.io/license
|
|
*/"><input type="hidden" name="files[app/keyup.components.ts]" value="/* tslint:disable:class-name component-class-suffix */
|
|
import { Component } from '@angular/core';
|
|
|
|
@Component({
|
|
selector: 'key-up1',
|
|
template: `
|
|
<input (keyup)="onKey($event)">
|
|
<p>{{values}}</p>
|
|
`
|
|
})
|
|
export class KeyUpComponent_v1 {
|
|
values = '';
|
|
|
|
/*
|
|
onKey(event: any) { // without type info
|
|
this.values += event.target.value + ' | ';
|
|
}
|
|
*/
|
|
|
|
onKey(event: KeyboardEvent) { // with type info
|
|
this.values += (<HTMLInputElement>event.target).value + ' | ';
|
|
}
|
|
}
|
|
|
|
//////////////////////////////////////////
|
|
|
|
@Component({
|
|
selector: 'key-up2',
|
|
template: `
|
|
<input #box (keyup)="onKey(box.value)">
|
|
<p>{{values}}</p>
|
|
`
|
|
})
|
|
export class KeyUpComponent_v2 {
|
|
values = '';
|
|
onKey(value: string) {
|
|
this.values += value + ' | ';
|
|
}
|
|
}
|
|
|
|
//////////////////////////////////////////
|
|
|
|
@Component({
|
|
selector: 'key-up3',
|
|
template: `
|
|
<input #box (keyup.enter)="onEnter(box.value)">
|
|
<p>{{value}}</p>
|
|
`
|
|
})
|
|
export class KeyUpComponent_v3 {
|
|
value = '';
|
|
onEnter(value: string) { this.value = value; }
|
|
}
|
|
|
|
//////////////////////////////////////////
|
|
|
|
@Component({
|
|
selector: 'key-up4',
|
|
template: `
|
|
<input #box
|
|
(keyup.enter)="update(box.value)"
|
|
(blur)="update(box.value)">
|
|
|
|
<p>{{value}}</p>
|
|
`
|
|
})
|
|
export class KeyUpComponent_v4 {
|
|
value = '';
|
|
update(value: string) { this.value = value; }
|
|
}
|
|
|
|
|
|
/*
|
|
Copyright 2016 Google Inc. All Rights Reserved.
|
|
Use of this source code is governed by an MIT-style license that
|
|
can be found in the LICENSE file at http://angular.io/license
|
|
*/"><input type="hidden" name="files[app/little-tour.component.ts]" value="import { Component } from '@angular/core';
|
|
|
|
@Component({
|
|
selector: 'little-tour',
|
|
template: `
|
|
<input #newHero
|
|
(keyup.enter)="addHero(newHero.value)"
|
|
(blur)="addHero(newHero.value); newHero.value='' ">
|
|
|
|
<button (click)="addHero(newHero.value)">Add</button>
|
|
|
|
<ul><li *ngFor="let hero of heroes">{{hero}}</li></ul>
|
|
`
|
|
})
|
|
export class LittleTourComponent {
|
|
heroes = ['Windstorm', 'Bombasto', 'Magneta', 'Tornado'];
|
|
addHero(newHero: string) {
|
|
if (newHero) {
|
|
this.heroes.push(newHero);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
Copyright 2016 Google Inc. All Rights Reserved.
|
|
Use of this source code is governed by an MIT-style license that
|
|
can be found in the LICENSE file at http://angular.io/license
|
|
*/"><input type="hidden" name="files[app/loop-back.component.ts]" value="import { Component } from '@angular/core';
|
|
@Component({
|
|
selector: 'loop-back',
|
|
template: `
|
|
<input #box (keyup)="0">
|
|
<p>{{box.value}}</p>
|
|
`
|
|
})
|
|
export class LoopbackComponent { }
|
|
|
|
|
|
/*
|
|
Copyright 2016 Google Inc. All Rights Reserved.
|
|
Use of this source code is governed by an MIT-style license that
|
|
can be found in the LICENSE file at http://angular.io/license
|
|
*/"><input type="hidden" name="files[main.ts]" value="import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
|
|
|
import { AppModule } from './app/app.module';
|
|
|
|
platformBrowserDynamic().bootstrapModule(AppModule);
|
|
|
|
|
|
/*
|
|
Copyright 2016 Google Inc. All Rights Reserved.
|
|
Use of this source code is governed by an MIT-style license that
|
|
can be found in the LICENSE file at http://angular.io/license
|
|
*/"><input type="hidden" name="files[styles.css]" value="/* Master Styles */
|
|
h1 {
|
|
color: #369;
|
|
font-family: Arial, Helvetica, sans-serif;
|
|
font-size: 250%;
|
|
}
|
|
h2, h3 {
|
|
color: #444;
|
|
font-family: Arial, Helvetica, sans-serif;
|
|
font-weight: lighter;
|
|
}
|
|
body {
|
|
margin: 2em;
|
|
}
|
|
body, input[text], button {
|
|
color: #888;
|
|
font-family: Cambria, Georgia;
|
|
}
|
|
a {
|
|
cursor: pointer;
|
|
cursor: hand;
|
|
}
|
|
button {
|
|
font-family: Arial;
|
|
background-color: #eee;
|
|
border: none;
|
|
padding: 5px 10px;
|
|
border-radius: 4px;
|
|
cursor: pointer;
|
|
cursor: hand;
|
|
}
|
|
button:hover {
|
|
background-color: #cfd8dc;
|
|
}
|
|
button:disabled {
|
|
background-color: #eee;
|
|
color: #aaa;
|
|
cursor: auto;
|
|
}
|
|
|
|
/* Navigation link styles */
|
|
nav a {
|
|
padding: 5px 10px;
|
|
text-decoration: none;
|
|
margin-right: 10px;
|
|
margin-top: 10px;
|
|
display: inline-block;
|
|
background-color: #eee;
|
|
border-radius: 4px;
|
|
}
|
|
nav a:visited, a:link {
|
|
color: #607D8B;
|
|
}
|
|
nav a:hover {
|
|
color: #039be5;
|
|
background-color: #CFD8DC;
|
|
}
|
|
nav a.active {
|
|
color: #039be5;
|
|
}
|
|
|
|
/* items class */
|
|
.items {
|
|
margin: 0 0 2em 0;
|
|
list-style-type: none;
|
|
padding: 0;
|
|
width: 24em;
|
|
}
|
|
.items li {
|
|
cursor: pointer;
|
|
position: relative;
|
|
left: 0;
|
|
background-color: #EEE;
|
|
margin: .5em;
|
|
padding: .3em 0;
|
|
height: 1.6em;
|
|
border-radius: 4px;
|
|
}
|
|
.items li:hover {
|
|
color: #607D8B;
|
|
background-color: #DDD;
|
|
left: .1em;
|
|
}
|
|
.items li.selected {
|
|
background-color: #CFD8DC;
|
|
color: white;
|
|
}
|
|
.items li.selected:hover {
|
|
background-color: #BBD8DC;
|
|
}
|
|
.items .text {
|
|
position: relative;
|
|
top: -3px;
|
|
}
|
|
.items .badge {
|
|
display: inline-block;
|
|
font-size: small;
|
|
color: white;
|
|
padding: 0.8em 0.7em 0 0.7em;
|
|
background-color: #607D8B;
|
|
line-height: 1em;
|
|
position: relative;
|
|
left: -1px;
|
|
top: -4px;
|
|
height: 1.8em;
|
|
margin-right: .8em;
|
|
border-radius: 4px 0 0 4px;
|
|
}
|
|
/* everywhere else */
|
|
* {
|
|
font-family: Arial, Helvetica, sans-serif;
|
|
}
|
|
|
|
|
|
/*
|
|
Copyright 2016 Google Inc. All Rights Reserved.
|
|
Use of this source code is governed by an MIT-style license that
|
|
can be found in the LICENSE file at http://angular.io/license
|
|
*/"><input type="hidden" name="files[user-input-styles.css]" value="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 }
|
|
|
|
/*
|
|
Copyright 2016 Google Inc. All Rights Reserved.
|
|
Use of this source code is governed by an MIT-style license that
|
|
can be found in the LICENSE file at http://angular.io/license
|
|
*/"><input type="hidden" name="files[app/app.component.html]" value="<p>
|
|
<click-me></click-me>
|
|
</p>
|
|
|
|
<p>
|
|
<click-me2></click-me2>
|
|
</p>
|
|
|
|
<h4>Give me some keys!</h4>
|
|
<div><key-up1></key-up1></div>
|
|
|
|
<h4>keyup loop-back component</h4>
|
|
<div><loop-back></loop-back></div>
|
|
<br><br>
|
|
|
|
<h4>Give me some more keys!</h4>
|
|
<div><key-up2></key-up2></div>
|
|
|
|
<h4>Type away! Press [enter] when done.</h4>
|
|
<div><key-up3></key-up3></div>
|
|
|
|
<h4>Type away! Press [enter] or click elsewhere when done.</h4>
|
|
<div><key-up4></key-up4></div>
|
|
|
|
<h4>Little Tour of Heroes</h4>
|
|
<p><i>Add a new hero</i></p>
|
|
<div><little-tour></little-tour></div>
|
|
|
|
<!--
|
|
Copyright 2016 Google Inc. All Rights Reserved.
|
|
Use of this source code is governed by an MIT-style license that
|
|
can be found in the LICENSE file at http://angular.io/license
|
|
-->"><input type="hidden" name="files[index.html]" value="<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>User Input</title>
|
|
<script>document.write('<base href="' + document.location + '" />');</script>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<link rel="stylesheet" href="styles.css">
|
|
<link rel="stylesheet" href="user-input-styles.css">
|
|
|
|
<!-- Polyfills -->
|
|
<script src="https://unpkg.com/core-js/client/shim.min.js"></script>
|
|
|
|
<script src="https://unpkg.com/zone.js@0.7.4?main=browser"></script>
|
|
<script src="https://unpkg.com/systemjs@0.19.39/dist/system.src.js"></script>
|
|
|
|
<script src="https://cdn.rawgit.com/angular/angular.io/b3c65a9/public/docs/_examples/_boilerplate/systemjs.config.web.js"></script>
|
|
<script>
|
|
System.import('main.js').catch(function(err){ console.error(err); });
|
|
</script>
|
|
</head>
|
|
|
|
<body>
|
|
<my-app>Loading...</my-app>
|
|
</body>
|
|
|
|
</html>
|
|
|
|
|
|
<!--
|
|
Copyright 2016 Google Inc. All Rights Reserved.
|
|
Use of this source code is governed by an MIT-style license that
|
|
can be found in the LICENSE file at http://angular.io/license
|
|
-->"><input type="hidden" name="tags[0]" value="angular"><input type="hidden" name="tags[1]" value="example"><input type="hidden" name="tags[2]" value="input"><input type="hidden" name="private" value="true"><input type="hidden" name="description" value="Angular Example - User Input"></form><script>document.getElementById("mainForm").submit();</script></body></html> |