<!DOCTYPE html>
<html>
<head>
<title>angular2 playground</title>
<link data-require="bootstrap-css@4.0.0-alpha.2" data-semver="4.0.0-alpha.2" rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/css/bootstrap.min.css" />
<link rel="stylesheet" href="style.css" />
<script src="https://code.angularjs.org/2.0.0-beta.17/angular2-polyfills.js"></script>
<script src="https://code.angularjs.org/tools/system.js"></script>
<script src="https://code.angularjs.org/tools/typescript.js"></script>
<script src="config.js"></script>
<script src="https://code.angularjs.org/2.0.0-beta.17/Rx.js"></script>
<script src="https://code.angularjs.org/2.0.0-beta.17/angular2.min.js"></script>
<script src="https://code.angularjs.org/2.0.0-beta.17/router.min.js"></script>
<script src="https://code.angularjs.org/2.0.0-beta.17/http.min.js"></script>
<script>
System.import('app')
.catch(console.error.bind(console));
</script>
<base href="." />
</head>
<body>
<my-app>
<div class="spinner"></div>
</my-app>
</body>
</html>
/* Styles go here */
.spinner {
width: 40px;
height: 40px;
background-color: #333;
margin: 100px auto;
-webkit-animation: sk-rotateplane 1.2s infinite ease-in-out;
animation: sk-rotateplane 1.2s infinite ease-in-out;
}
@-webkit-keyframes sk-rotateplane {
0% { -webkit-transform: perspective(120px) }
50% { -webkit-transform: perspective(120px) rotateY(180deg) }
100% { -webkit-transform: perspective(120px) rotateY(180deg) rotateX(180deg) }
}
@keyframes sk-rotateplane {
0% {
transform: perspective(120px) rotateX(0deg) rotateY(0deg);
-webkit-transform: perspective(120px) rotateX(0deg) rotateY(0deg)
} 50% {
transform: perspective(120px) rotateX(-180.1deg) rotateY(0deg);
-webkit-transform: perspective(120px) rotateX(-180.1deg) rotateY(0deg)
} 100% {
transform: perspective(120px) rotateX(-180deg) rotateY(-179.9deg);
-webkit-transform: perspective(120px) rotateX(-180deg) rotateY(-179.9deg);
}
}
.loading{
background-color: #d35400;
}
### Angular2 Starter Plunker - Typescript - RC.0
A simple plunker demonstrating Angular2 usage:
- Uses SystemJS + TypeScript to compile on the fly
- Includes binding, directives, http, pipes, and DI usage.
System.config({
//use typescript for compilation
transpiler: 'typescript',
//typescript compiler options
typescriptOptions: {
emitDecoratorMetadata: true
},
//map tells the System loader where to look for things
map: {
app: "./src",
'@angular': 'https://npmcdn.com/@angular',
'rxjs': 'https://npmcdn.com/rxjs@5.0.0-beta.6'
},
//packages defines our app package
packages: {
app: {
main: './main.ts',
defaultExtension: 'ts'
},
'@angular/core': {
main: 'core.umd.js',
defaultExtension: 'js'
},
'@angular/compiler': {
main: 'compiler.umd.js',
defaultExtension: 'js'
},
'@angular/common': {
main: 'common.umd.js',
defaultExtension: 'js'
},
'@angular/platform-browser-dynamic': {
main: 'platform-browser-dynamic.umd.js',
defaultExtension: 'js'
},
'@angular/platform-browser': {
main: 'platform-browser.umd.js',
defaultExtension: 'js'
},
rxjs: {
defaultExtension: 'js'
}
}
});
//main entry point
import {bootstrap} from 'angular2/platform/browser';
import {provide, bind} from 'angular2/core';
import {ROUTER_PROVIDERS, ROUTER_BINDINGS} from 'angular2/router';
import {App} from './app';
bootstrap(App, [
ROUTER_PROVIDERS
]);
//our root app component
import {Component} from 'angular2/core'
import {RouteConfig, Router, Route, ROUTER_DIRECTIVES} from 'angular2/router';
import {Login} from './login';
import {Dashboard} from './dashboard';
@Component({
selector: 'my-app',
template: `
<h1>Wellcome To {{name}}</h1>
<a [routerLink]="['Dashboard']">Dashboard</a> |
<a [routerLink]="['Login']">Login</a>
<hr>
<router-outlet></router-outlet>
`,
directives: [ROUTER_DIRECTIVES]
})
@RouteConfig([
new Route({path: '/dashboard', name: 'Dashboard', component: Dashboard}),
new Route({path: '/login', name: 'Login', component: Login, useAsDefault:true})
])
export class App {
constructor(public router: Router) {
this.name = 'Angular2 App'
}
reload(){
location.reload();
}
}
import {Component} from 'angular2/core'
import {RouteConfig, Router, Route, ROUTER_DIRECTIVES} from 'angular2/router';
@Component({
selector: 'dashboard',
template: `
<div style="color:red">dashboard!!!:</div> `
})
export class Dashboard {
constructor(public router: Router) {
}
}
import {Component} from 'angular2/core'
import {RouteConfig, Router, Route, ROUTER_DIRECTIVES} from 'angular2/router';
import { NgForm } from '@angular/common';
@Component({
selector: 'login',
templateUrl:'src/loginTemplate.html'
})
export class Login {
public email: string;
public password: string;
constructor(public router: Router){}
login(){
alert(this.email+' '+this.password)
// this.router.navigate(['Layout']);
}
}
<div class="container">
<form (ngSubmit)="login()">
<div class="form-group">
<label for="email">Email</label>
<input type="text" class="form-control" required
[(ngModel)]="email" ngControl="emailctrl" #emailctrl="ngForm"
>
<div [hidden]="emailctrl.valid || emailctrl.pristine" class="alert alert-danger">
Email is required
</div>
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" class="form-control" required
[(ngModel)]="password" ngControl="passctrl" #passctrl="ngForm"
>
<div [hidden]="passctrl.valid || passctrl.pristine" class="alert alert-danger">
Passwd is required
</div>
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
</div>