Atmosphere.js 包,angular-模板,在我的绑定中对小于运算符抛出错误

Atmosphere.js package, angular-templates, throws error on less than operator in my binding

抛出错误

=> Errors prevented startup:                  

   While processing files with angular-templates (for target web.browser):
   client/templates/rcalendar/day.html:7: Expected tag name after `<`
   ...            {{$index<12?($index === 0?12:...
   ^
   client/templates/rcalendar/week.html:16: Expected tag name after `<`
   ...            {{$index<12?($index === 0?12:...

冒犯HTML

<td class="calendar-cell">
   <div class="add_event_shade" style="height:100%;" ng-if="!tm.events" ng-show"clickCount" on-touch="hourTouch($event)">
      <p style="display:none;">+ New event</p>
      <p style="display:none;">{{$index<12?($index === 0?12:$index)+':00 am':($index === 12?$index:$index-12)+':00 pm'}}</p>
   </div>
   <div ng-class="{'calendar-event-wrap': tm.events}" ng-show="tm.events">
      <div ng-repeat="displayEvent in tm.events" 
             class="calendar-event" 
             ng-click="eventSelected({event:displayEvent.event})"
             ng-style="{left: 100/displayEvent.overlapNumber*displayEvent.position+'%', width: 100/displayEvent.overlapNumber+'%', top: displayEvent.event.startTimeOffset+'%', height: 37*(displayEvent.event.totalApptTime)+'px'}">
          <div class="calendar-event-inner" style="white-space: pre-wrap; font-weight: bold">{{displayEvent.event.title}}</div>
      </div>
   </div>
</td>

如何在我的绑定中设置条件?

我认为你必须这样做:

<p style="display:none;">
    {{($index < 12 && $index === 0)? 12 : $index}}:00 am
    {{$index === 12? $index : ($index - 12)}}:00 pm
</p>

但是要小心,你在 p 标签里放了一个 display:none


编辑: 正如评论中所讨论的那样,为了避免 angular-template 给出的错误,我们可以从控制器调用一个函数,而不是评估 p 标签

<p>{{getTime($index)}}</p>