0
this.Title을 사용하여 getHeroes() 메서드에서 "title"속성을 읽을 수 있습니다. console.log를 볼 수는 있지만 "영웅"속성은 볼 수 없습니다. 나는 "this.heroes [0] .id" "this.heroes"와 정의되지 않은 모든 것을 시도했다. 하지만 console.log (자바 스크립트 콘솔)에서 모든 속성을 표시합니다. 내가 뭐 잘못하고있는거야?각도 2 읽지 않은 json 속성 json 속성이 정의되지 않음 기타 속성 ok
감사
export class AppComponent implements OnInit {
title = 'Tour of Heroes';
heroes: Hero[];
selectedHero: Hero;
rows: Object[];
constructor(private heroService: HeroService) { }
getHeroes() {
this.heroService.getHeroes().then(heroes => this.heroes = heroes);
//console.log("get heroes: "+this);
}
getRows(){
var n = 3;
for(var i=0; i<1;i++){
console.log(this.title);
}