import {Plan} from './plan.model';
export class PlanService{
private plans:Plan[]=[
new Plan("5:00","reading"),
new Plan("6:00","writing"),
new Plan("7:00","cleaning")
];
getPlan(){
return this.plans.slice();//returns the plan
}
setPlan(time,plan){
this.plans.push(new Plan(time,plan));
}
}
我在上面尝试过将新的Plan对象推入定义的数组中,但这不起作用。
答案 0 :(得分:0)
这可能对您有帮助
`setPlan(time,plan){
this.plans.push(new plan(){time : time , plan : plan})
};`