在这个例子中如何使用Angularjs内联条件?

时间:2015-07-22 00:08:14

标签: angularjs

对于下面的代码,如果{{schedules.position}} = {{position.position}}?

          .positions(ng-repeat='position in positions')
            .row
              {{position}}
              .row
              .col-sm-4.col-md-4
              .col-sm-8.col-md-8
                .schedule(ng-repeat='schedule in schedules')
                  .row
                    .col-sm-1.col-md-1.
                      %input(ng-model = "string" type = 'checkbox')
                    .col-sm-7.col-md-7.
                      %table
                        %tr
                          %td
                           {{schedule.first_name}}

3 个答案:

答案 0 :(得分:0)

是的...只需删除{{}}并使用比较运算符

<div ng-if="schedules.position == position.position">

让我转换为html,因为我不熟悉您的模板语法

答案 1 :(得分:0)

使用ng-showng-hideng-ifng-switch

答案 2 :(得分:0)

在您的范围内添加一个可以过滤的功能。

$scope.filterSchedule = function(pos) { 
    return _.filter(schedules, function(sch) { 
        return sch.position == pos; });
    }

然后你的内心重复可能是

ng-repeat="schedule in filterSchedule(position)"