[S02E04][新手村] Directive & Pipe

[S02E04][新手村] Directive & Pipe 相關的討論於此

參考資料:

1個讚

想問關於Observable.of <T>
影片裡面有提到Observable.of<Item> 型別的問題,我看到這篇


但是我試著把型別置入,卻出現錯誤
this.items = Observable.of<Item>([
{
id: 1,
name: ‘mosluce’
},
{
id: 2,
name: ‘hello’
},
{
id: 3,
name: ‘hello world’
}
]);
}
[ts]
Argument of type ‘{ id: number; name: string; }[]’ is not assignable to parameter of type ‘Item | SchedulerLike’.
Type ‘{ id: number; name: string; }[]’ is not assignable to type ‘SchedulerLike’.
Property ‘now’ is missing in type ‘{ id: number; name: string; }[]’.
請問有人知道這是為什麼嗎? 感謝~

你的 of 裡面型別改成 item[],原因是 of 裡的資料是一個陣列

1個讚