2016-04-04 18 views
0

Verileri bir veritabanına ileten işlevler için modellenen bir görünüm var. Her şey çalışıyor ve geri çağrıldığında geri gelen verileri görüyorum ama geri döndüğümde alanlarımı önceden doldurmuyor. Kafamı bir süredir becermeye başladım. Her şey (ne söyleyebilirim) doğru şekilde modellenmiştir.Svc Modellemeden Görünüm Elemanlarına Modellenmeyen Veriler AngularJS

Aşağıdaki JS kodunu Chrome'da adım adım attı ve verilerden $ kapsam değişkenlerine atanan verileri görüyorum.XXX dönüşü.

Ancak, yükleme bittikten sonra, radyo düğmem ön seçimini yapmıyor veya alanları veriyle doldurmuyor. Herhangi bir yardım büyük beğeni topluyor. İşte

Görünüm geçerli:

<div class="notification-container"> 
     <form name="notificationForm" class="form-horizontal" ng-submit="saveQrNotifications()"> 
     <div class="list-unstyled"> 
      <input id="text" ng-model="NotificationMethods.NotificationMethodId" ng-change="notifyVisible()" name="text" type="radio" ng-value="1001"> Text Message<br> 
      <input id="email" ng-model="NotificationMethods.NotificationMethodId" ng-change="notifyVisible()" name="email" type="radio" ng-value="6"> Email<br> 
      <input id="voice" ng-model="NotificationMethods.NotificationMethodId" ng-change="notifyVisible()" name="voice" type="radio" ng-value="1003"> Voice<br> 
      <input id="nocontact" ng-model="NotificationMethods.NotificationMethodId" ng-change="notifyVisible()" name="nocontact" type="radio" ng-value="1000"> Do Not Contact<br> 
     </div> 

     <div class="col-md-12 notification-fields" ng-show="notifyFieldVisibility == true"> 
      <div class="col-md-12" ng-if="NotificationMethods.NotificationMethodId == '1001'"> 
       <label class="notication-input">Text Number</label> 
        <span class="clearfix"></span> 
        <input class="form-control area-code" type="text" ng-model="NotificationMethods.NotificationTextAreaCode" placeholder="(555)" required> 
        <input class="form-control phone-number" type="text" ng-model="NotificationMethods.NotificationTextPhoneNumber" placeholder="555-5555" required> 
      </div> 
      <div class="col-md-12" ng-if="NotificationMethods.NotificationMethodId == '6'"> 
       <label class="notification-input" for="email">E-mail Address 
        <input class="form-control" id="email" name="email" type="text" ng-model="NotificationMethods.NotificationEmailAddress" placeholder="[email protected]" required> 
       </label> 
      </div> 
      <div class="col-md-12" ng-if="NotificationMethods.NotificationMethodId == '1003'"> 
       <label class="notication-input">Voice Number </label> 
       <span class="clearfix"></span> 
        <input class="form-control area-code" type="text" ng-model="NotificationMethods.NotificationVoiceAreaCode" placeholder="(555)" required> 
        <input class="form-control phone-number" type="text" ng-model="NotificationMethods.NotificationVoicePhoneNumber" placeholder="555.5555" required> 
       <label class="small">Ext.</label> 
       <input class="form-control extension" type="text" ng-model="NotificationMethods.NotificationVoiceExtension" placeholder="555"> 
      </div> 
      <span class="clearfix"></span> 
      <div ng-show="notifyLoading" class="text-center" style="margin-top: 10px;"> 
       <i class="fa fa-spinner fa-spin"></i> Saving... 
      </div> 
      <div class="col-md-12"> 
       <button type="submit" class="btn btn-primary notification-btn">Save Notifications</button> 
      </div> 

     </div> 
     </form> 

</div> 

İşte benim denetleyicisi geçerli:

VERİ DB GELEN:

if (data.StatusCode == "SUCCESS") { 
      $scope.refill = data; 
      //$scope.deliverTypes = data.DeliveryTypes; 
      $scope.showError = false; 
      $scope.submitRefill = true; 
      $scope.findRefillStatus = userMessageService.QuickRefillMessage(data.Prescriptions[0]); 
      $scope.isRefillable = data.Prescriptions[0].IsRefillable; 
      $scope.prescription.noPrescription.$valid = true; 
      $scope.loading = false; 
      $scope.NotificationMethods.NotificationEmailAddress = data.NotificationEmailAddress; 
      $scope.NotificationMethods.NotificationMethodId = data.NotificationMethodId; 
      $scope.NotificationMethods.NotificationTextAreaCode = data.NotificationTextAreaCode; 
      $scope.NotificationMethods.NotificationTextPhoneNumber = data.NotificationTextPhoneNumber; 
      $scope.NotificationMethods.NotificationVoiceAreaCode = data.NotificationVoiceAreaCode; 
      $scope.NotificationMethods.NotificationVoicePhoneNumber = data.NotificationVoicePhoneNumber; 
      $scope.NotificationMethods.NotificationVoiceExtension = data.NotificationVoiceExtension; 
     } 
+0

jsfiddle oluşturabilir misiniz? –

+0

Biraz zaman alacaktır, bu parçanın aksiyon unsurlarını yukarıda anlattığım gibi, gerçekten de jsfiddle için refactor yapmak zorunda kalacağım ng-if/show elemanlarına biraz da yer var. –

cevap

0

bunu çözdü. Denetleyiciyi ng-include içinde kullanılan görünümde bildiriyordum. Bunu kaldırarak ve görünümü çevredeki görünümden denetleyici devralmasına izin vermek sorunu çözüldü.