0
我在使用角度數據表選擇某個數據時如何觸發事件有問題。如何在角度數據表select上創建回調函數
我想啓用編輯和刪除按鈕,當有一個選定的行。
這裏是我的代碼:
app.controller('SampleController', function($http, DTOptionsBuilder, DTColumnBuilder, $q) {
var vm = this;
vm.dtOptions = DTOptionsBuilder.fromFnPromise(function() {
var defer = $q.defer();
$http.get("{!! url('sample/api/v1/questions?questionType=1') !!}")
.then(function(response) {
defer.resolve(response.data.active_question_contents);
});
return defer.promise;
})
.withDOM('frtip')
.withPaginationType('full_numbers')
.withDisplayLength(5)
.withButtons([{
text: 'Add',
key: '1',
action: function(e, dt, node, config) {
alert('Add');
}
}, {
text: 'Edit',
key: '2',
action: function(e, dt, node, config) {
alert('Edit');
},
enabled: false
}, {
text: 'Delete',
key: '3',
action: function(e, dt, node, config) {
alert('Delete');
},
enabled: false
}])
.withSelect({
style: 'os',
selector: 'td:first-child'
});
我試圖drawCallback但它只能觸發一次。