2016-12-14 32 views
0

我只是想使用此代碼:UI-Grid gridOptions - > selectOptions as Variable not possible?

field: 'field1', 
filter: { 
    term: 1, 
    condition: uiGridConstants.filter.STARTS_WITH, 
    placeholder: 'starts with...', 
    ariaLabel: 'Starts with filter for field1', 
    flags: { caseSensitive: false }, 
    type: uiGridConstants.filter.SELECT, 
    //selectOptions: [{ value: '1', label: 'male' }, { value: '2', label: 'female' }], 
    selectOptions: [$scope.DropdownEntries], 
    disableCancelFilterButton: false 
}     

的gridOptions selectOption陣列回來形式DropdownEntries是空的,因爲如果gridOptions沒有設置在DropdownEntries()的變量是無法訪問的,它們來自互聯網服務和加載它們需要更長的時間,因爲gridOptions被設置。

在確定所有變量都可以訪問後,有沒有可能「重新加載」gridOptions?或者有另一種方法來解決這個問題

  • 我是AngularJS和Ui-Grid的新人,感謝您的幫助!

回答

0

你可以用一個空數組初始化selectOptions當數據變爲可用

this問題重新分配。

0

那麼你應該等待承諾得到解決,集selectOptions後,這樣的事情:

$http.get(url).then(function(response) { 
    gridOptions.filter.selectOptions = response.data.dropdownEntries; 
}) 

另一種可能性是進入該設置界面網格選項控制器之前解決這一承諾。 https://docs.angularjs.org/api/ngRoute/service/ $ route#example

相關問題