具有3个Jsons的AngularJS ng-repeat表

时间:2016-07-20 08:53:49

标签: angularjs json foreach ng-repeat

我想在AngularJS中创建一个表

它是一个假期刨床。

它应该是这样的:

              day   day   day   day   day   day   day   day   day   day   day   day
employeename color color color color color color color color color color color color
employeename color color color color color color color color color color color color
employeename color color color color color color color color color color color color

我得到了3天不同的Jsons的日子,雇员和颜色,以及每个员工。

员工json:

[{
  name: "John Doe",
  short: "JD",
  group: "J's Group",
  degree_short: "CEO",
  degree: "Chief Executive Officer",
  department: "Management"
 }]

Days Json:

     [{
       weekday: "Fr",
       day: "25",
       date: 1450998000000
       }]

和我的假期Json:

     [{
       short: "twi",
       first_date: 1468965600000,
       end_date: 1468965600000,
       reason: 1
     }]

问题是,NG-Repeat只重复一个Json,但我需要 它像:

  angular.forEach(staff, function (users, key) {
        angular.forEach(days, function (dates, key) {
            angular.forEach(vacations, function (vacation, key) {
                if (holidays.krzl == users.krzl) {
                    if (holidays.first_date <= dates.date && holidays.end_date >= dates.date) {
                        if (holidays.reason == '0') {
                            return color = "grey";
                        } else if (holidays.reason == '1') {
                            return color = "green";
                        } else if (holidays.reason == '2') {
                            return color = "red";
                        } else if (holidays.reason == '3') {
                            return color = "blue";
                        }
                    }
                }
            });
        });
    });

但是我不能简单地用PHP中的echos生成一个表..

有人有想法吗?

编辑:这是一张Plunk,其中包含我当前的状态:https://plnkr.co/edit/dt0s4WAc1foln9jOsK3f?p=preview

0 个答案:

没有答案