개체 배열 병합에 문제가 있습니다. 내 목표는 하나에 3 배열을 병합하고 서버에 HTTP POST를 보냅니다.각도 2의 개체 병합
나는 CONCAT를 사용하지만, 필자가이 오류가 시도 :
예외 : ./PreviewEmailPage 클래스 PreviewEmailPage_Host의 오류 - 인라인 템플릿 : 0 : 0으로 인한 : 정의되지 않은
의 특성 'CONCAT'을 읽을 수 없습니다 다음은 내 코드입니다 : this.localStorage.get
이후
import { Component } from '@angular/core';
import { NavParams, NavController, LoadingController } from 'ionic-angular';
import { Validators, FormGroup, FormControl } from '@angular/forms';
import { Http, Headers} from '@angular/http';
import 'rxjs/add/operator/map';
import { Storage } from '@ionic/storage';
@Component({
selector: 'preview-email-page',
templateUrl: 'preview-email.html',
})
export class PreviewEmailPage {
headers: Headers;
loading: any;
url: string;
preview: any[];
FirstArray: any[];
SecondArray: any[];
ThirdArray: any[];
PostData: any[];
constructor(
public nav: NavController,
public navParams: NavParams,
public loadingCtrl: LoadingController,
public localStorage: Storage,
public http: Http,
) {
this.localStorage.get('FirstArray').then((value) => {
this.FirstArray= value;
})
this.localStorage.get('SecondArray').then((value) => {
this.SecondArray= value;
})
this.localStorage.get('ThirdArray').then((value) => {
this.ThirdArray= value;
})
this.PostData = this.FirstArray.concat(this.SecondArray);
this.PostData = this.PostData.concat(this.ThirdArray);
this.loading = this.loadingCtrl.create();
}
ionViewWillEnter(){
this.headers = new Headers();
this.headers.append("Content-Type", "application/x-www-form-urlencoded");
console.log(this.PostData);
this.getPreview();
}
getPreview(){
this.loading.present();
this.url = 'https://domain.com/REST/getpreview.php';
this.http.post(this.url, this.PostData, {headers: this.headers}).map(res => res.json()).subscribe(res => {
console.log(res);
this.preview = res;
}, err => {
console.log('error');
})
}
}
다음 (...)'로컬 저장소에서 가져 오는 일이 일어나고 *. * 비동기식 **. 따라서 연결에 도달 할 때까지는 해당 입력란이 아직 설정되지 않았습니다. – jonrsharpe