如何为每行数据隔离另一个NgRepeat?

时间:2019-06-28 10:04:41

标签: html angularjs

我有如下观点。消息“员工上班了四个小时吗?” 是对安德鲁的警告消息。单行中可以有多个警告消息。如何隔离警告消息?因为此处的警告消息仅适用于安德鲁。也许问题是,我该如何正确实施?

这是我的html代码:

<tbody>
    <tr ng-repeat-start="itm in vm.service.timeSheet.TicketTimesheetsDetails">

      <td>
        <i ng-if="(itm.ErrorCount > 0 || itm.WarningCount > 0) && !vm.service.isCollapsed" class="icon icon-chevron-right" ng-click="vm.service.isCollapsed = true">
          <md-tooltip>
            Show timesheet validation(s)
          </md-tooltip>
        </i>
        <i ng-if="(itm.ErrorCount > 0 || itm.WarningCount > 0) && vm.service.isCollapsed" class="icon icon-chevron-down" ng-click="vm.service.isCollapsed = false">
          <md-tooltip>
            Show timesheet validation(s)
          </md-tooltip>
        </i>

      </td>

      <td>
        <i class="icon icon-clipboard-account" ng-click="vm.service.showRoleDialog(itm)" style="color:steelblue">
          <md-tooltip>
              {{vm.service.changeRoleCaption}}
          </md-tooltip>
        </i>
      </td>

      <td>
        {{itm.AllocatedItemName}}
      </td>

      <td>
        <md-input-container>
          <input ng-attr-id="{{'TravelStartTime-' + $index}}"
                 type="text"
                 ng-focus="vm.service.disableSaveButton()"
                 ng-change="vm.service.onTextChange('#TravelStartTime-' + $index)"
                 ng-disabled="vm.service.isLocked"
                 aria-label="Travel Start"
                 ng-blur="vm.service.validateLine(itm, 1, 'TravelStartTime',  $index, itm.TravelStartTime, true)"
                 ng-model="itm.TravelStartTime"
                 time-picker>
        </md-input-container>
      </td>
      <td>
        <md-input-container>
          <input ng-attr-id="{{'JobStartTime-' + $index}}"
                 type="text"
                 ng-disabled="vm.service.isLocked"
                 aria-label="Job Start"
                 ng-focus="vm.service.disableSaveButton()"
                 ng-change="vm.service.onTextChange('#JobStartTime-' + $index)"
                 ng-blur="vm.service.validateLine(itm, 2, 'JobStartTime',  $index, itm.JobStartTime, true)"
                 ng-model="itm.JobStartTime"
                 ng-class="{'has-error': vm.service.isFieldValid(itm, 'JobStartTime')}"
                 time-picker>
        </md-input-container>
      </td>
     </tr>
    <tr ng-repeat="validation in vm.service.timesheetValidations" ng-if="vm.service.isCollapsed" ng-repeat-end="">]
      <td class="validation-section">
          &nbsp; 
      </td>
      <td class="validation-section">
          <i class="icon icon-alert" style="color: #ff7316;">
            </i>
      </td>
      <td colspan="4" class="validation-section">
            {{ validation.Message }}
      </td>
    </tr>

这是on-blur方法,其中正在生成警告消息(api调用):

timeSheetApi
                .validate(clonedTimesheet)
                .then(function (resp) {

                    var validationErrors = resp.data;

                    line.ErrorCount = 0;
                    line.Errors = '';
                    line.WarningCount = validationErrors.length;

                    if (validationErrors.length > 0) {
                        line.ErrorCount = validationErrors.length;
                        service.timesheetValidations = validationErrors; //these are the Warning Messages

0 个答案:

没有答案