export class UsersComponent() { }
import (Component) from 'angular/core';
export class UsersComponent() { }
import (Component) from 'angular/core';
@Component({
selector: 'users',
templateUrl: './users.component.html'
})
export class UsersComponent() { }
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)
}
}
<span>{{interpolatedValue + getValue() + 4}}</span>
Ne jamais utiliser les [] si :
<img [src]="logo.jpg" />
<img [attr.src]="logo.jpg" />
<span [style.color]="componentStyle">Some colored text!</span>
<button (click)="alertTheWorld()">Click me!</button>
<md-input-container>
<label>The awesome input</label>
<input md-input [(ngModel)]="dynamicValue"
placeholder="Watch the text update!" type="text"> </md-input-container>
<br>
<span>{{dynamicValue}}</span>
<div *ngIf=”userIsVisible”>{{user.name}}</div>
<template [ngIf]="userIsVisible">
<div>{{user.name}}</div>
</template>
<img src="logo.jpg" #myImage />
{{myImage.src}}
<md-input-container>
<label>Type to see the value</label> <input md-input type="text" #input />
</md-input-container>
<strong>{{input?.value}}</strong>