Итак, я создал следующий класс:
export class PresentObject {
public type: string;
public resourceUrl: string;
public text: string;
}
И следующий компонент:
import {Component, Input, OnInit} from '@angular/core';
import {PresentObject} from '../classes/present-object';
@Component({
selector: 'app-video',
templateUrl: './video.component.html',
styleUrls: ['./video.component.css']
})
export class VideoComponent implements OnInit {
@Input()
view: PresentObject;
constructor() {
}
ngOnInit() {
console.log(this.view.text);
}
}
Теперь я пытаюсь вставить это через HTML:
<section *ngFor="let view of views; let last = last" [ngSwitch]="view.type">
<app-video *ngSwitchCase="'video'" view="{{view}}"></app-video>
<span *ngIf="last">{{repeatComplete()}}</span>
</section>
После отладки я вижу, могу ли я console.log(this.view)
получить: "[object Object]"
Может кто-нибудь сказать мне, что я сделал неправильно?