2017-01-16 32 views
1

試圖使用鍵入框中的文本提交自動完成搜索框。我可以使用onValueChanged,但它會觸發每個按鍵。我需要搜索輸入時按下。我嘗試了一些東西,但無法解決問題。這是一個dxToolbar的一部分:如何使用DevExtreme在angularJS中獲取自動完成文本框值

{ 
    location: 'after', 
    widget: 'dxAutocomplete', 
    options: { 
    width: '340px', 
    placeholder: 'Enter title, category or identifier', 
    dataSource: PageAutoCompleteDataSource($http), 
    bindingOptions: { 
     searchText: 'text' 
    }, 
    onChange: function(e){ 
     console.log('Value searched ' + $scope.searchText); 
     DevExpress.ui.notify("Searching for " + $scope.searchText); 

    } 
    } 
} 

不要去管什麼數據源等,我只需要知道如何在任何onXX事件得到當前的價值?

回答

1

看起來你正在尋找的onEnterKey事件處理程序:

$scope.autocompleteOptions = { 
    //... 
    onEnterKey: function(e) { 
     var selectedValue = e.component.option("value"); 
     DevExpress.ui.notify("Searching for " + selectedValue); 
    } 
}; 

Demo

+0

是的這是正確的,但它是'e.component.option( 「值」)'那我不能」從文檔中解脫出來。謝謝。 –

相關問題