2016-12-16 43 views
0

在下面的示例代碼片段中,我如何分配從表達式{{(results | filter: myFilter)}}返回的數據爲數據屬性而不是results如何在AngularJS中爲表達式賦值爲數據屬性

<img ng-json-export-excel data="results" src=../dl.png/> 

下面是我的試驗沒有奏效。

data="{{(results | filter: myFilter)}}" 
data="results | filter: myFilter" 

請指教。

謝謝, 雷迪。

回答

1

按如下方式在js中執行過濾器工作。現在

$scope.filteredResults = filter1Filter(results, myFilter);

在HTML中,你可以這樣做:

<img ng-json-export-excel data="{{filteredResults}}" src=../dl.png/>

這可以幫助你。祝一切順利。

+0

是的,這是打我的解決方案之一,但我想利用表達式,並在html頁面本身。有可能的? – Reddy

+1

在HTML頁面中做它會大大降低性能。最好在js上做。 – SaiUnique

+1

閱讀這篇文章。這可以幫助你[鏈接](https://toddmotto.com/use-controller-filters-to-prevent-digest-performance-issues/) – SaiUnique