我正在制作待办事项应用程序,它从文件B获取任务然后将其显示到文件A,问题是我无法将数组从B推送到A,这是错误。我还是编程的新手,所以请放轻松我...
这是代码:
src/pages/addtask/addtask.ts
import { Component } from '@angular/core';
import { NavController, IonicPage, NavParams } from 'ionic-angular';
import { HomePage } from '../home/home';
import { Storage } from '@ionic/storage'
@Component({
selector: 'page-task',
templateUrl: 'addtask.html'
})
export class AddTask {
// from here
tasks = []
post(){
this.tasks.push(this.tasks);
this.HomePage.avtasks.push(this.tasks);
}
constructor(public navCtrl: NavController, private storage: Storage, public HomePage) {
}
close(){
this.navCtrl.pop();
}
}
src/pages/home/home.ts
import { Component } from '@angular/core';
import { NavController, IonicPage, NavParams } from 'ionic-angular';
import { AddTask } from '../addtask/addtask'
import { Storage } from '@ionic/storage';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
// to here
avtasks:any[] = []
constructor(public navCtrl: NavController, private storage: Storage) {
}
openCT(){
this.navCtrl.push(AddTask);
}
}
提前致谢!
答案 0 :(得分:0)