1
내 firebase 데이터베이스의 데이터로 텍스트 영역을 채우려고합니다. ngModel을 사용해야한다는 것을 알고 있지만 구문에 다소 차질이 있습니다.DB/ng2에서 텍스트 영역 채우기
<textarea rows="3" cols="35" [(ngModel)]=""> read from db.. </textarea>
비어있는 ""에서 나는 HttpService.getData(); 그러나 그것은 작동하지 않았다. 또한 http.service.ts.getData()를 작성하려고했지만 그 중 하나도 작동하지 않았습니다.
아래 코드를 사용하면 콘솔에 응답을 출력 할 수 있으므로 어떻게 든 사용해야합니다 ... 아무에게도 어떻게 말해 줄 수 있습니까?
@Injectable()
export class HttpService {
constructor(private http: Http) { }
getData() {
return this.http.get('https://URL-HERE.json').map((response: Response) => response.json());
}
}
@Component({
selector: 'message-form',
templateUrl: './message-form.component.html',
providers: [HttpService]
})
export class MessageFormComponent implements OnInit{
constructor(private httpService: HttpService) { }
ngOnInit(){
this.httpService.getData()
.subscribe(
(data: any) => console.log(data));
}
아를 , 무리 감사! 그 트릭을 했어 :) –
다행, 듣고 당신은 대단히 환영합니다! :) – Alex