Knockout JS: Filter an Array

雖然只在兩個小型專案中使用過 Knockout JS,儘管語法稍嫌囉嗦了點,但能大幅減少前端頁面互動功能開發的難度。

最近碰到一個功能是頁面載入後,透過 AJAX 向 Server 端取回 JSON 資料,接著用 KO 顯示成列表。需求是能像 Mac OS 的 Spotlight 那樣,輸入文字即時顯示搜尋結果。

因為這串資料的變動頻率不高,所以從 KO 的 observableArray 過濾就可以了。


Posted

in

,

by

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Exit mobile version