Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
智能表-AngularJs-Wrap在指令内_Angularjs_Angularjs Directive_Smart Table - Fatal编程技术网

智能表-AngularJs-Wrap在指令内

智能表-AngularJs-Wrap在指令内,angularjs,angularjs-directive,smart-table,Angularjs,Angularjs Directive,Smart Table,我对AngularJs非常陌生,并尝试将智能表插件“包装”到指令中。 我可以获取行,但分页未显示 现在我就是这么做的 app.directive('grid', [ function () { return { restrict: 'E', replace: true, template: function (element, attrs) { return '<table class="table t

我对AngularJs非常陌生,并尝试将智能表插件“包装”到指令中。 我可以获取行,但分页未显示

现在我就是这么做的

    app.directive('grid', [ function () {
    return {
        restrict: 'E',
        replace: true,
        template: function (element, attrs) {
            return '<table class="table table-striped">'
                          + '<thead>'
                          + '    <tr>'
                                  + '<th st-ratio="20" st-sort="Team">Team</th>'
                                  + '<th st-ratio="20" st-sort="TeamFreq">Team Freq</th>'
                                  + '<th st-ratio="10" st-sort="TeamSac">Team Sac</th>'
                                  + '<th st-ratio="30" st-sort="Priority">Priority</th>'
                              + '</tr>'
                          + '</thead>'
                          + '<tbody>'
                              + '<tr ng-repeat="row in dataset">'
                                 + ' <td>{{row.firstName}}</td>'
                                  + '<td>{{row.lastName | uppercase}}</td>'
                                  + '<td>{{row.age}}</td>'
                                  + '<td>{{row.email}}</td>'
                              + '</tr>'
                          + '</tbody>'
                          + '<tfoot>'
                              + '<tr>'
                                 + '<td colspan="4" class="text-center">'
                                  + '<div class="pagination pagination-xs m-top-none pull-right"  st-pagination="1" st-items-by-page="itemsByPage" st-displayed-pages="4"></div>'
                                  + '</td>'
                              + '</tr>'
                          + '</tfoot>'
                      + '</table>';

        },
        scope: {

        },
        controller: function ($scope) {

        },
        link: function (scope, elem, attrs) {
            var nameList = ['Pierre', 'Pol', 'Jacques', 'Robert', 'Elisa'], familyName = ['Dupont', 'Germain', 'Delcourt', 'bjip', 'Menez'];
            function createRandomItem() {
                var
                    firstName = nameList[Math.floor(Math.random() * 4)],
                    lastName = familyName[Math.floor(Math.random() * 4)],
                    age = Math.floor(Math.random() * 100),
                    email = firstName + lastName + '@@whatever.com',
                    balance = Math.random() * 3000;

                return {
                    firstName: firstName,
                    lastName: lastName,
                    age: age,
                    email: email,
                    balance: balance
                };
            }

            scope.rowCollection = [];
            for (var j = 0; j < 10; j++) {
                scope.rowCollection.push(createRandomItem());
            }
            scope.dataset = [].concat(scope.rowCollection);
        }
    };
}]);
app.directive('grid',[function(){
返回{
限制:'E',
替换:正确,
模板:函数(元素、属性){
返回“”
+ ''
+ '    '
+“团队”
+“团队频率”
+“Sac团队”
+“优先权”
+ ''
+ ''
+ ''
+ ''
+“{row.firstName}”
+“{row.lastName |大写}}”
+“{row.age}”
+“{row.email}”
+ ''
+ ''
+ ''
+ ''
+ ''
+ ''
+ ''
+ ''
+ ''
+ '';
},
范围:{
},
控制器:功能($scope){
},
链接:功能(范围、要素、属性){
var nameList=['Pierre'、'Pol'、'Jacques'、'Robert'、'Elisa'],familyName=['Dupont'、'Germain'、'Delcourt'、'bjip'、'Menez'];
函数createRandomItem(){
变量
firstName=nameList[Math.floor(Math.random()*4)],
lastName=familyName[Math.floor(Math.random()*4)],
年龄=Math.floor(Math.random()*100),
email=firstName+lastName+'@@whatever.com',
balance=Math.random()*3000;
返回{
名字:名字,
lastName:lastName,
年龄:年龄,,
电邮:电邮,,
平衡:平衡
};
}
scope.rowCollection=[];
对于(var j=0;j<10;j++){
scope.rowCollection.push(createRandomItem());
}
scope.dataset=[].concat(scope.rowCollection);
}
};
}]);
我的html包含这个标签

  <grid st-table="dataset"></grid>

此代码只是一个测试,数据将使用服务传递。。模板将是动态的。 我需要一些帮助:-)


谢谢

前几天我在指令中使用智能表时,无法显示分页。结果证明它与指令无关,我只是从GitHub拉/更新到最新版本的smart table,一切正常。我开始关注改变了的东西,但却偏离了方向,转向了更有成效的东西,很高兴它现在起作用了。 我的版本似乎运行良好,标记为1.4.2


但是,对于来自服务的动态数据,我认为您也需要查看st safe src属性。虽然我对Angular/smart table的整个业务也不熟悉。

我相信您必须匹配st表值和st分页值才能显示分页