내 firebase 데이터베이스에서 데이터를 가져옵니다. 이 t에서 내 HTML을각도 2의 모델로 함수
import { Component, OnInit } from '@angular/core';
import { DomSanitizer, SafeResourceUrl, SafeUrl, SafeHtml } from '@angular/platform-browser';
import { ActivatedRoute } from '@angular/router';
import { RealEstatePhotography } from '../real-estate-photography';
import { RealEstatePhotographyService } from '../real-estate-photography.service';
@Component({
selector: 'app-real-estate-photography-detail',
templateUrl: './real-estate-photography-detail.component.html',
styleUrls: ['./real-estate-photography-detail.component.css'],
providers: [RealEstatePhotographyService],
})
export class RealEstatePhotographyDetailComponent implements OnInit {
photos = this.photo();
realEstate;
constructor(private route: ActivatedRoute, private _realEstatePhotographyService: RealEstatePhotographyService, private sanitizer: DomSanitizer) { }
photo(){
var location = ""
for (var i = 0; i < location.length; i++){
Array(i);
}
return console.log(Array(i));
}
ngOnInit(){
this.route.params.subscribe(params => {
let title = params['title'];
let realEstate = this._realEstatePhotographyService.getItem(title).subscribe(realEstate => {
this.realEstate = realEstate
});
});
}
}
입니다 :
이 내 service.ts
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import {Http, Response, RequestOptions} from '@angular/http';
import { RealEstatePhotography } from './real-estate-photography';
import {AngularFire, FirebaseListObservable} from 'angularfire2';
import 'rxjs/add/operator/map';
@Injectable()
export class RealEstatePhotographyService {
constructor(private af: AngularFire, private http: Http) { }
private realEstate = this.af.database.list('realestate');
getItems(){
return (this.realEstate);
}
getItem(title: RealEstatePhotography) : Observable<any>{
return this.realEstate
.map((list: Array<any>) => {
let result: RealEstatePhotography = new RealEstatePhotography();
if (list){
list.forEach(element => {
if (element.title === title){
result = element
}
});
return result;
}
});
}
}
이 내 세부 구성 요소입니다 모자 구성 요소.
지금, 내 질문은 :
이
<p>{{realEstate.folder}}</p>
같은
는뭔가.
은 내가 당신이 무엇에 완전히 명확하지 않다
https://plnkr.co/edit/a0WKevpXpwvY8x7NG1cb?p=preview
플 런커를 제공 하시겠습니까? –
나는 그 문제를 이해하지 못한다. "나는 그 결과를 '위치 변수'에 넣어야한다. 당신이 달성하고자하는 것을 설명하십시오. – Per
Per, 조금 혼란 스럽습니다. 설명하기가 정말 어려웠습니다. 결과가 페이지에 표시됩니까? 음, 그 데이터를 위치 에 저장해야합니다 : var location = ""https://s3.amazonaws.com/gadaphotos/photos/portfolio/alden_park/ " 하지만 내 firebase에서 해당 데이터를 가져옵니다. {{realEstate.folder}}를 넣고 그 데이터를 얻습니다. 같은 데이터를 가져 오기 위해 var location = {{realEstate.folder}}와 비슷한 것을 넣고 싶습니다. 감사합니다. –