2017-10-21 87 views
1

je le modèle suivant:ng-model ne fonctionne pas dans ng-if et ng-repeat, AngularJs?

<tr ng-repeat="dailyInformation in TradodModel.Model.EmployeeDayRelatedData.DailyInformation track by $index" ng-click="DailyInformationRowOnClick(dailyInformation, $event)" data-selected="{{dailyInformation.IsSelected}}" data-rowindex="{{dailyInformation.RowIndex}}"> 
     <td ng-if="!IsHourlyContract() && DailyOverShowType() != @((short) DailyOverShowTypeEnumeration.NotShow) && !DailyOverType()" data-changed="{{dailyInformation.HasOverTimeChange()}}" title="{{dailyInformation.OverTimeTitle()}}" class="{{BgCssClass()}}"> 
      @if (ViewBag.HasWritePermission) 
      { 
       @Html.BootstrapTimeTextBox("OverTimeTextBox", "", false, false, 2, false, 
       new Dictionary<string, object> 
       { 
        {"data-disableindexing", "true"}, 
        {"ng-if", "DailyOverShowType() == " + (short)DailyOverShowTypeEnumeration.Editable}, 
        {"ng-model", "dailyInformation.OverTimeFormatted"}, 
        {"ng-disabled", "ViewOnlyMode()"}, 
        {"ng-keydown", "TradodOverTimeOnKeyDown(dailyInformation, $event)"}, 
        {"ng-keyup", "TradodOverTimeOnKeyUp($event)"}, 
        {"ng-focus", "TradodOverTimeOnFocus($event)"}, 
        {"ng-blur", "TradodOverTimeOnBlur()"}, 
        {"data-overtime-index", "{{dailyInformation.RowIndex}}"} 
       }) 
      } 
      else 
      { 
       <div style="width: 50px;" ng-if="DailyOverShowType() == @((short)DailyOverShowTypeEnumeration.JustShow)">{{dailyInformation.OverTimeFormatted1()}}</div> 
      } 
      </td> 
</tr> 

La ligne suivante fonctionne pas: { "modèle ng-", "dailyInformation.OverTimeFormatted"}

et dailyInformation.OverTimeFormatted ne met pas à jour si je change la valeur textbox !

Répondre

1

ng-model est not supposed to work dans les ng-if

En général, vous pouvez éviter cela avec ng-model="$parent.dailyInformation.OverTimeFormatted"

+0

'ng modèle = "$ parent.dailyInformation.OverTimeFormatted"' fonctionne pas –