angular使用service应用分层
step0:创建一个新项目
step1: 创建服务user和组件user
ng generate service user
ng generate component user
step2: 创建bean类 D:\vue\untitled2899\src\app\user.ts
export class User {
id: number;
name: string;
address: string;
constructor(id: number, name: string, address: string) {
this.id = id;
this.name = name;
this.address = address;
}
}
step3: 创建本地资源库 D:\vue\untitled2899\src\app\mock-users.ts
import {
User} from "./user";
export const USERS : User[] = [
{
id:11,name:'李明',address:'北京'},
{
id:12,name:'刘洪',address:'上海'},
{
id:13,name:'赵雄',address:'深圳'},