StrictTemplate 抱怨 SortDirection 不是字串。但是,列舉是一個字串,不是嗎?
型別“字串”不可分配給型別“排序方向”。
<mat-table matSort matSortDirection="{{ this.sort.direction }}" ...
SortDirection 的定義是:
匯出宣告型別 SortDirection = 'asc' | '降序' | '';
有沒有辦法將其轉換為字串?
我嘗試過matSortDirection="{{(string)this.sort.direction}}",matSortDirection="{{this.sort.direction.toString()}}"但失敗了。
轉換它的最佳方法是什么?
uj5u.com熱心網友回復:
您可以嘗試添加幫助$any器來告訴編譯器,這里沒有錯,一切都正確
<mat-table matSort matSortDirection="{{ $any(this.sort.direction) }}" ...
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/444561.html
標籤:有角度的
