Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/421.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/73.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.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
Javascript 动态结果数组需要使用Angular JS与具有不同布局的表绑定_Javascript_Jquery_Angularjs_Arrays_Html Table - Fatal编程技术网

Javascript 动态结果数组需要使用Angular JS与具有不同布局的表绑定

Javascript 动态结果数组需要使用Angular JS与具有不同布局的表绑定,javascript,jquery,angularjs,arrays,html-table,Javascript,Jquery,Angularjs,Arrays,Html Table,我有一个数组的动态结果,它需要与表绑定,但使用Angular JS会有一些不同的布局。我尝试了很多次,但没有成功。我要求得到理想的结果。我们非常感谢你的帮助 var-arr=[ { “唯一id”:“CS”, “学院”:“理学学士”, “arr_长度”:1, “程序部分”:[ { “问题”:“你如何评价你的老师”, “总数”:135, }, { “问题”:“你对你的老师满意吗”, “总数”:142, }, { “问题”:“在整个课程中,你最喜欢哪门课程”, “总数”:135, }, { “问题”

我有一个数组的动态结果,它需要与表绑定,但使用Angular JS会有一些不同的布局。我尝试了很多次,但没有成功。我要求得到理想的结果。我们非常感谢你的帮助

var-arr=[
{
“唯一id”:“CS”,
“学院”:“理学学士”,
“arr_长度”:1,
“程序部分”:[
{
“问题”:“你如何评价你的老师”,
“总数”:135,
},
{
“问题”:“你对你的老师满意吗”,
“总数”:142,
},
{
“问题”:“在整个课程中,你最喜欢哪门课程”,
“总数”:135,
},
{
“问题”:“你对导师的评价有多高”,
“总数”:137,
},
]
},
{
“唯一id”:“MBA”,
“学院”:“工商管理学士”,
“arr_长度”:2,
“程序部分”:[
{
“问题”:“你如何评价你的老师”,
“总数”:175,
},
{
“问题”:“你对你的老师满意吗”,
“总数”:142,
},
{
“问题”:“在整个课程中,你最喜欢哪门课程”,
“总数”:165,
},
{
“问题”:“你对导师的评价有多高”,
“总数”:137,
},
]
},
{
“唯一id”:“CA”,
“学院”:“账户”,
“arr_长度”:1,
“程序部分”:[
{
“问题”:“你如何评价你的老师”,
“总数”:145,
},
{
“问题”:“你对你的老师满意吗”,
“总数”:162,
},
{
“问题”:“在整个课程中,你最喜欢哪门课程”,
“总数”:125,
},
{
“问题”:“你对导师的评价有多高”,
“总数”:117,
},
]
}
];
var-app=angular.module('myApp',[]);
app.controller('customersCtrl',函数($scope,$http){
$scope.names=arr;
});

问题:
{{x.学院}
{{y.问题}
{{y.total}

您必须先循环桌面的所有元素,然后再循环身体的所有元素。我用了一个固定的数字来循环你的问题。您只需修改过滤器即可

HTML

<div ng-app="myApp" ng-controller="customersCtrl">
    <table border="1">
        <thead>
        <tr>
            <td>Question</td>
            <td ng-repeat="x in names">{{ x.college }}</td>
        </tr>
        </thead>
        <tbody>
        <tr ng-repeat="n in [] | range:4">
            <td>
                {{ names[0].program_section[n].question }}
            </td>
            <td width="100px" ng-repeat="x in names">
                {{ x.program_section[n].total }}
            </td>
        </tr>
        </tbody>
    </table>
</div>

问题:
{{x.学院}
{{names[0]。程序_部分[n]。问题}
{{x.program_section[n].total}
Javascript

var app = angular.module('myApp', []);
app.controller('customersCtrl', function($scope, $http) {
    $scope.names = arr;
}).filter('range', function() {
  return function(input, total) {
    total = parseInt(total);

    for (var i=0; i<total; i++) {
      input.push(i);
    }

    return input;
  };
});
var-app=angular.module('myApp',[]);
app.controller('customersCtrl',函数($scope,$http){
$scope.names=arr;
}).filter('范围',函数()){
返回函数(输入,总计){
总计=parseInt(总计);

对于(var i=0;i你必须循环所有元素到表头,然后再循环到你的主体。我在这里使用了一个固定的数字来循环你的问题。你可以简单地修改过滤器,tho

HTML

<div ng-app="myApp" ng-controller="customersCtrl">
    <table border="1">
        <thead>
        <tr>
            <td>Question</td>
            <td ng-repeat="x in names">{{ x.college }}</td>
        </tr>
        </thead>
        <tbody>
        <tr ng-repeat="n in [] | range:4">
            <td>
                {{ names[0].program_section[n].question }}
            </td>
            <td width="100px" ng-repeat="x in names">
                {{ x.program_section[n].total }}
            </td>
        </tr>
        </tbody>
    </table>
</div>

问题:
{{x.学院}
{{names[0]。程序_部分[n]。问题}
{{x.program_section[n].total}
Javascript

var app = angular.module('myApp', []);
app.controller('customersCtrl', function($scope, $http) {
    $scope.names = arr;
}).filter('range', function() {
  return function(input, total) {
    total = parseInt(total);

    for (var i=0; i<total; i++) {
      input.push(i);
    }

    return input;
  };
});
var-app=angular.module('myApp',[]);
app.controller('customersCtrl',函数($scope,$http){
$scope.names=arr;
}).filter('范围',函数()){
返回函数(输入,总计){
总计=parseInt(总计);

因为(var i=0;我想你救了我一天谢谢你救了我一天