我是Angular 4的新秀,我需要一些帮助.我在控制台中的代码显示错误但在我的模板中一切显示正确.有人能帮我理解发生了什么吗?
错误
ERROR TypeError: Cannot read property 'Tytul' of undefined
NewsDetailsComponent.html:7 ERROR CONTEXT DebugContext_ {view: Object, nodeIndex: 12, nodeDef: Object, elDef: Object, elView: Object}
Run Code Online (Sandbox Code Playgroud)
news.ts
export interface News {
Ident: number;
Tytul: string;
Tresc: string;
Data: string;
Run Code Online (Sandbox Code Playgroud)
}
news.service.ts
import { Injectable } from '@angular/core';
import { Http, Response, Headers, RequestOptions } from '@angular/http';
import { Observable } from 'rxjs/Observable';
import 'rxjs/Rx';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/toPromise';
import { News } from './news';
@Injectable()
export class NewsService {
private newsUrl …Run Code Online (Sandbox Code Playgroud)