【问题标题】:fooTable not working properly in AngularJSfooTable 在 AngularJS 中无法正常工作
【发布时间】:2015-10-21 12:41:11
【问题描述】:

我在 AngularJS 中遇到 fooTable 的问题,这就是我正在做的事情:

<table class="table m-b-none" ui-jq="footable" data-filter="#filter" data-page-size="5">
    <thead>
        <tr>
            <th data-toggle="true">Name</th>
            <th data-hide="phone">Logo</th>
            <th data-hide="phone,tablet">Website</th>
            <th data-hide="phone,tablet" data-name="Friendly URL">URL</th>
            <th data-hide="all">External Parameter 1</th>
            <th data-hide="all">External Parameter 2</th>
            <th data-hide="all">Meta Keywords</th>
            <th data-hide="all">Meta Description</th>
            <th data-hide="all">Period</th>
            <th>Action</th>
        </tr>
    </thead>
    <tbody>
        <tr ng-repeat="store in stores">
            <td>{{store.name}}</td>
            <td><img ng-src="{{store.logo}}" /></td>
            <td>{{store.website}}</td>
            <td>{{store.friendly_url}}</td>
            <td>{{store.external_parameter1}}</td>
            <td>{{store.external_parameter2}}</td>
            <td>{{store.meta_keywords}}</td>
            <td>{{store.meta_description}}</td>
            <td>{{store.period}}</td>
            <td data-value="1">
                <!--Edit Button-->
                <a type="button" class="btn btn-xs btn-default" ui-sref="app.store.edit({editId: store.id})">
                    <i class="fa fa-pencil"></i>
                </a>
                <!--Delete Button-->
                <a type="button" class="btn btn-xs btn-default" ng-click="deleteStore(store.id)">
                    <i class="fa fa-trash"></i>
                </a>
            </td>
        </tr>
    </tbody>
    <tfoot class="hide-if-no-paging">
        <tr>
            <td colspan="10" class="text-center">
                <ul class="pagination"></ul>
            </td>
        </tr>
    </tfoot>
</table>

当我按F5 刷新页面时,输出应该是这样的:

然后在我点击其他地方e.g. Add Store 并返回此页面后,现在图片发生了变化:

+ 图标消失了,所有&lt;td&gt; 都显示出来了,它们并没有像应有的那样隐藏起来。

这是我的控制器:

app.controller('storesCtrl', ['$scope', '$http', function($scope, $http) {
    $scope.stores = {};
    $http.get("http://MyApiUrl/store.php").
    success(function(data){
        $scope.stores = data;
        //$('.table').trigger('footable_redraw');
    });
}]);

我也尝试过使用 $('.table').trigger('footable_redraw');,但没有成功。

请帮忙,谢谢

【问题讨论】:

    标签: angularjs footable


    【解决方案1】:

    我找到了解决办法:

    success(function(data){
        $scope.stores = data;
        $timeout(function(){
            $('.table').trigger('footable_redraw');
        }, 100);
    });
    

    【讨论】:

    • 'footable_redraw' 是我想要的。谢谢。
    猜你喜欢
    • 2016-05-08
    • 2014-11-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-02
    相关资源
    最近更新 更多