Angular ng-repeat在FF中可以正常工作,在Chrome中以某种方式注释掉

时间:2013-05-22 12:03:57

标签: google-chrome angularjs

我在jsp中有这个代码(大小一点):

<div class="popup default" ng-app="interview" ng-init="employeeId = '${employee.id}'; findTimelineEntries(); getAddInterviewRights(); getEditInterviewRights();" ng-controller="TimelineCtrl">
  <div class="box-wrapper edit" ng-show="hasAddInterviewRights">
    <div class="box">
      <div class="pointer"></div>
      <div class="box-content">
        <div class="icon close" ></div>
        <div class="form-item">
        <!-- cut -->
        </div>
      </div>

      <div class="form" id="convo">
        <div class="form-item">
          <!-- cut -->
        </div>
        <div class="form-break"></div>
        <div class="form-item">
          <div class="label">
            <div class="fi-content">
              Currently open goals
            </div>
          </div>
          <div class="value">
            <div class="editable" ng-repeat="goal in interviewForm.goals" ng-click="openEditable($event.target)">
              <div class="icon edit"></div>
              <div class="icon close" ng-click="closeEditable($event.target)"></div>
                {{goal.shortDescription}}
              <div class="ed-content">
              <div class="form-item">
                <div class="label">
                <div class="fi-content">
                  Deadline
                </div>
              </div>
              <div class="value">
                <input type="text" ng-model="goal.dueDate" ui-date="dateOptions" size="15" />
              </div>
            </div>
            <div class="form-item">
              <div class="label">
                <div class="fi-content">
                  Status
                </div>
              </div>
            <div class="value select">
              <select ng-model="goal.status" ng-options="code as description for (code, description) in goalStatusses"></select>
            </div>
          </div>
          <div class="form-item">
            <div class="label">
              <div class="fi-content">
                Comment
              </div>
            </div>
            <div class="value">
              <div class="fi-content">
                <table class="plain">
                  <tr ng-repeat="progress in goal.progresses">
                    <td>{{progress.progressDate | date: 'dd-MM-yyyy'}}</td>
                    <td>{{progress.progressReport}}</td>
                  </tr>
                </table>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="editable">
        <div class="icon add"></div>
          <div class="icon close" ng-click="closeEditable($event.target)"></div>
          Add a new goal

它可以在Firefox(20.0.1)中运行:它显示了2个当前目标和添加新目标的选项。但不知何故,同样的jsp在Chrome(27)中效果不佳,因为它只显示添加新目标的选项

使用开发人员工具查看HTML时,我发现Chrome注释了ng-repeat,但为什么会这样做?

我搜索了ng-repeat被注释掉了,但答案是使用ng-repeat的div不在ng-controller的div中,但我的代码肯定不是这样的

从开发人员工具中获取的HTML:

<div class="value">
  <!-- ngRepeat: goal in interviewForm.goals -->
  <div class="editable">
    <div class=icon add"></div>
    <div class=icon close" ng-click="closeEditable($event.target)" style="dispay:none;"></div>
      Add new goal

我已经检查了其他浏览器,它在Safari(5.1)中也不起作用,并且在IE8中也不起作用,尽管一位同事说它在IE9中有效

1 个答案:

答案 0 :(得分:1)

好吧,我终于找到了出错的地方,实际上是

    $('.select .option').click(function() {
    var choice = $(this).text();
        etc.

必须改为

$(".select #itemAddSelector").change(function(){
    var selectedOption = $(this).children(":selected");
    var choice = $(selectedOption).text();
        etc.

由于从未在Chrome中调用从控制器检索目标的功能,因为Chrome不会对选项(Click event on select option element in chrome)处理jQuery点击事件。 所以它只是在关于ng-repeat的HTML中评论说它曾试图迭代目标对象,但是没有对象存在...... pfff,我一直在错误的方向看太久。