import { Component } from '@angular/core';
@Component({
selector: 'app-root',
template: `{{title}}
`,
})
export class AppComponent {
title = 'app works!';
}
<body>
<app-root>Loading...</app-root>
</body>
La boite à outils pour Angular 2.
Programme Node, installable avec NPM.
$ ng new APP_NAME
$ ng serve
$ ng generate TYPE NAME
$ ng build --prod
$ ng test
export class MyComponent {
action : string = 'Valider';
changeAction(event) {
this.action = this.action == 'Valider' ? 'Annuler' : 'Valider';
}
}
- {{language}}
export class MyComponent {
isValid : boolean = false;
languages = ['Java', 'Javascript', 'ruby', 'python', 'scala'];
}
@Component({
selector: 'parent',
template: `
`,
})
export class ParentComponent {
parameter : string = 'toursJs';
oneFunction(event) {
// Event is "ok"
//Do something
}
}
export class ChildComponent {
@Output() customEvent = new EventEmitter();
//customEvent.emit("ok");
@Input() oneInput: any;
}
const routes: Routes = [
{path: '', component : AppRoot},
{path: 'profil/:id', component : ProfilComponent},
{path: 'dashboard' , component : DashboardComponent,
canActivate: [LoggedInGuard, OnlyAdminGuard]},
];
export const routing = RouterModule.forRoot(routes, { useHash: true });
<a [routerLink]="['/profil', user.id]">
goToProfil() {
this.router.navigate(['/profil', this.user.id]);
}