Les concepts fondamentaux
export class UsersComponent() { }
export class AboutComponent implements OnInit {
title: string = 'About Page'
body: string = 'This is the about page body'
message: string
constructor(public _stateService: StateService) { }
ngOnInit() {
this.message = this._stateService.getMessage()
}
updateMessage(m: string): void {
this._stateService.setMessage(m)
}
}
import (Component) from 'angular/core';
export class UsersComponent() { }
import (Component) from 'angular/core';
@Component({
selector: 'users',
templateUrl: './users.component.html'
})
export class UsersComponent() {
@Input() name: String;
}
import (Component) from 'angular/core';
export interface User {
firstname: string
lastname: string
}
@Component({
selector: 'users',
templateUrl: './users.component.html'
})
export class UsersComponent() {
users: User[]
defaultUser: User = {
firstname: 'Default Firstname',
lastname: 'Default Lastname',
}
constructor(
private _userService: UserService
) {
updateUser(index:number, user: User) {
this.users = this._userService.update(index, user)
}
}
import (Component) from 'angular/core';
import {UserComponent} from './user/user.component'
export interface User {
firstname: string
lastname: string
}
@Component({
selector: 'users',
templateUrl: './users.component.html',
directives: [UserComponent]
})
export class UsersComponent() {
users: User[]
defaultUser: User = {
firstname: 'Default Firstname',
lastname: 'Default Lastname',
}
constructor(
private _userService: UserService
) {
updateUser(index:number, user: User) {
this.users = this._userService.update(index, user)
}
}
import (Component, OnInit) from 'angular/core';
import {UserComponent} from './user/user.component'
@Component({
selector: 'users',
templateUrl: './users.component.html',
directives: [UserComponent]
})
export class UsersComponent implements OnInit () {
users: User[]
defaultUser: User = {
firstname: 'Default Firstname',
lastname: 'Default Lastname',
}
constructor(
private _userService: UserService
) {
ngOnInit() {
this.users = this._userService.get()
}
updateUser(index:number, user: User) {
this.users = this._userService.update(index, user)
}
}