2016-04-04 3 views
0

Ich habe eine View, die Funktionen modelliert, die Daten an eine Datenbank weiterleiten. Das funktioniert alles und ich sehe, dass die Daten zurückkommen, wenn sie aufgerufen werden, aber es füllt die Felder in meiner Sicht nicht vor, wenn es zurückkommt. Ich habe mir dafür eine Weile den Kopf geschlagen. Alles ist richtig modelliert (von dem, was ich sagen kann).Daten von der Serviceeinheit werden nicht in View-Elemente modelliert AngularJS

Ich bin durch den JS-Code unten in Chrome gegangen und sehe die Daten, die meinen $ scope-Variablen von der data.XXX Rückkehr zugewiesen werden.

Aber, nach dem Laden beendet, ist es nicht Vorauswahl meines Optionsfelds oder Füllen der Felder mit den Daten. Jede Hilfe sehr geschätzt. Hier

ist die Ansicht:

<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> 

Hier ist mein Controller:

DATEN AUS DB COMING:

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

Können Sie jsfiddle erstellen? –

+0

Es wird ein wenig dauern, ich habe wirklich nur die Action-Elemente für dieses Stück oben gezeigt, es ist ziemlich involviert für ng-if/show-Elemente, die ich für jfiddle umgestalten muss. –

Antwort

0

es herausgefunden. Ich erklärte den Controller auf die in ng-include verwendete Ansicht. Dies zu entfernen und den View von der Umgebungsansicht erben zu lassen, wurde behoben.

Verwandte Themen