Ejemplo 1: crear una clase de modelo angular
// to create a model class, we first need to create a new file
//f.e person.ts
export class Person {
constructor(
public name: string,
public lastName: string,
public age:number
) {}
}
//now that we have the model class we can create arrays that contain Person class elements
.
.
public people: Person[];
constructor(){
this.people = [
new Person ('Carla','Smith', 20 ),
new Person ('Carlos','Smith', 25 ),
new Person ('Andrea','Johnson', 23 ),
];
}
Ejemplo 2: crear clase angular
// to create a model class, we first need to create a new file
//f.e person.ts
export class Person {
constructor(
public name: string,
public lastName: string,
public age:number
) {}
}
//now that we have the model class we can create arrays that contain Person class elements
.
.
public people: Person[];
constructor(){
this.people = [
new Person ('Carla','Smith', 20 ),
new Person ('Carlos','Smith', 25 ),
new Person ('Andrea','Johnson', 23 ),
];
}
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)