REST 서비스에서 HTML을 검색하고 각도 (4.3)를 사용하여 표시하려고합니다. 서비스가 호출되어 올바른 내용을 반환하는 것을 볼 수 있습니다. 그러나 이것을 사용하는 각 구성 요소는 실제로 내용을 수신하지 못합니다. 나는 무엇을 놓쳤는가?서버에서 html을 가져 와서 각도로 표시
구체적으로 (아래 번째 코드 샘플)을 console.log(html)
항상 널 출력한다.
@Injectable()
export class SlidesService {
private requestUrl: string;
constructor(
@Inject(AppConfig) private config: AppConfig,
@Inject(HttpClient) private http: HttpClient) {
this.requestUrl = this.config.restRoot + listSlidesUrl;
}
getSlide(deck: string, slide: string): Observable<string> {
const headers: HttpHeaders = new HttpHeaders({'Accept': 'text/html'});
const thisUrl: string = this.requestUrl + '/' + deck + '/' + slide;
return this.http.get<string>(thisUrl, { headers: headers });
}
}
이 컴퍼넌트에 의해 사용되는 :
이export class SlidePreviewComponent implements OnInit {
@Input() slide: string; /* Identifier for the slide */
@Input() deck: string;
slideHtml: string;
constructor(private slideService: SlidesService) {
}
ngOnInit(): void {
this.slideService.getSlide(this.deck, this.slide)
.subscribe(html => this.setSlideHtml(html));
}
setSlideHtml(html: string) {
this.slideHtml = html;
console.log(html);
}
}
가 호출되는/올바른 내용을 반환 할 수 있습니다 (서비스중인 console.log, 가입 한 console.log 또는 브라우저의 XML을보고 있습니까?) 첫 번째 추측은 반환 된 응답이 문자열이 아닌 객체이므로 파싱하는 방법을 알지 못하지만 여기에 정확한 정보가 없습니다. –
"응용 프로그램 서버가 로컬에서 실행 중이고 출력물을 추적 중입니다." –