ng-table:将数据标题放入ng-repeat中为什么不起作用?另一种方法?

时间:2014-10-13 13:08:06

标签: angularjs coffeescript pug angularjs-ng-repeat ngtable

我在项目中使用Jade和coffeescript。

我的玉代码:

table.table(ng-table="videoTableParams", show-filter="true")

    tr(ng-repeat="video in $data")
        td(data-title="'Name'", sortable="'name'", filter="{ 'name': 'text' }")
            a(ui-sref="video.info({ videoId: video.id })") {{ video.name }}
        td(data-title="'Format'", sortable="'format'", filter="{ 'format': 'text' }") {{ video.format }}
        td(data-title="'Duration [s]'", sortable="'duration'") {{ video.duration | number:0 }}
        td(ng-repeat="buttons in controlButtons")
            {{ buttons.title }}
            button#btnRemove.btn.btn-sm.btn-info(ng-show="buttonShow({ videoId: video.id , state:buttons.detail.show , value: 0})", data-toggle="tooltip", data-placement="bottom", title="{{ buttons.detail.title }}", ng-click="clickFunction({ videoId: video.id , function: buttons.detail.click })")
                span.glyphicon.glyphicon-wrench
                button#btnRemove.btn.btn-sm.btn-info(ng-show="video.prepare_state == 0", data-toggle="tooltip", data-placement="bottom", title="{{ buttons.detail.title }}", ng-click="clickFunction({ videoId: video.id , function: buttons.detail.click })")
            .progress(ng-show="buttonShow({ videoId: video.id , state:buttons.detail.show , value: 2})")
                .progress-bar.progress-bar-striped.active(role='progressbar', aria-valuenow='60', aria-valuemin='0', aria-valuemax='100', style='width: 100%;')
                    .bar(style='width: 20%;')
            button#btnRemove.btn.btn-sm.btn-success(ng-show="buttonShow({ videoId: video.id , state: buttons.detail.show , value: 1 })", data-toggle="tooltip", data-placement="bottom", title="{{ buttons.detail.title }}", ng-click="clickFunction({ videoId: video.id , function: buttons.detail.click })")
                span.glyphicon.glyphicon-ok

        td(data-title="")
            button#btnRemove.btn.btn-sm.btn-danger(ng-hide="video.file_exist", data-toggle="tooltip", data-placement="bottom", title="Remove this video", ng-click="showRemoveVideoModal(video)")
                span.glyphicon.glyphicon-trash

我的coffeescript代码:

# Prepare table copmonent
    $scope.videoTableParams = new ngTableParams({
        page: 1,            # show first page
        count: 10,          # count per page
        sorting: {
            name: 'asc'     # initial sorting
        },
        filter: {
            name: ''
        }
    }, {
        total: $scope.videos.length, # length of data
        getData: ($defer, params) ->
            # use build-in angular filter
            orderedData = if params.sorting() then $filter('orderBy')($scope.videos, params.orderBy()) else $scope.videos
            filteredData = if params.filter() then $filter('filter')(orderedData, params.filter()) else orderedData

            $scope.filteredVideos = filteredData.slice((params.page() - 1) * params.count(), params.page() * params.count())
            params.total(filteredData.length)
            $defer.resolve($scope.filteredVideos)
    })

我认为使用数据标题它不会起作用,因为我的所有按钮标题只有一个标题。

如果我在这个td中有数据标题

td(ng-repeat="buttons in controlButtons" , data-title="buttons.title") 

按钮是未定义的,我尝试了很多解决方案作为controlButton [$ index] [' title']但是$ index不起作用所以我做了一个随机标题和它的工作,但只有一个标题的所有列,我认为数据标题不动态。我试着用thead做这个,但我没有排序和过滤....

感谢您的回复!

0 个答案:

没有答案