如何在角度数据表数据源中使用变量

时间:2016-04-29 12:24:16

标签: javascript angularjs angular-ui-router

我想做这样的事情:

app.controller('fltInfoController', function($scope, $http,DTOptionsBuilder, DTColumnBuilder, $resource,$q) {
 var vm = this;
 vm.isTableShown = false;
 $scope.fltNumber;
   vm.getIssueList = function() {

    $http({
        url: "./searchXYZAction",
        method: "GET",
        params: {fltNumber: $scope.fltNumber}
 }).success(function(response){
    alert("success");
    vm.isTableShown = true;
        // vm.list = response;

vm.message = '';
vm.someClickHandler = someClickHandler;
vm.dtOptions = DTOptionsBuilder.fromFnPromise(function() {
    return $resource(response).query().$promise;
})
    .withPaginationType('full_numbers')
    .withOption('bSortCellsTop', true)
    .withOption('aLengthMenu', [ 5,10, 25, 50, 100 ])

    .withColumnFilter({
    sPlaceHolder: "head:after",

        aoColumns: [{
            type: 'text',
            bRegex: true,
            bSmart: true
        }, {
            type: 'number'
        }, {
           type: 'text',
            bRegex: true,
            bSmart: true
        },{
           type: 'text',
            bRegex: true,
            bSmart: true
        }, {
            type: 'text',
            bRegex: true,
            bSmart: true
        }]
    });

vm.dtColumns = [

    //DTColumnBuilder.newColumn('issueTitle').withTitle('Title'),
    DTColumnBuilder.newColumn('carrIataCd').withTitle('Raised By'),
    DTColumnBuilder.newColumn('fltNumber').withTitle('Issue Number'),
    DTColumnBuilder.newColumn('origArptCd').withTitle('Type ID'),
    DTColumnBuilder.newColumn('destArptCd').withTitle('Module ID'),
    DTColumnBuilder.newColumn('fltLclOrigDt').withTitle('Priority Number')

];

    }).
        error(function(data, status, headers, config) {
            alert("error");
          });


   }

如上所示,首先,我想使用$ http GET进行服务器调用,然后使用返回值作为数据表数据源。但是这段代码没有运行。我正在获取数据,但数据表未使用该变量。请帮忙。

0 个答案:

没有答案