2016-04-09 21 views
0

içinde yayınlanmadan sonra gösterilmiyor Form verileri göndermeye çalışıyorum ancak içerik kullanıcı arabiriminde güncelleştirilmiyor. Aşağıdaki kod çalışıyor, verileri yayınlıyor ama tags, {{tag.Title}}'da güncelleştirilmiyor. Form verileri AngularJS

$scope.saveTag = function (data,TagTypeId) { 
 
     var result = employeeCvService.addTag(data, TagTypeId, $scope.consultantCv.Id).success(function(data){ 
 
      var new1 = data; 
 
      $scope.consultantCv.TagsbyTypes[0].Tags.push(newtag); 
 
     }); 
 
     // $scope.consultantCv.TagsbyTypes[0].Tags.push(newtag); //this code is not updating the binding in the UI 
 
    };
<div class="row" data-ng-repeat="tagsByType in consultantCv.TagsbyTypes" ng-init="init('tag',2000)"> 
 
<div class="col-md-12"> 
 
<hr /> 
 
<h2> 
 
    <i class="icons8-{{tagsByType.CssClass}}" aria-hidden="true"></i>{{tagsByType.Title}} 
 
</h2> 
 
    <div class="tags"> 
 
     <div class="input-group" ng-controller="consultantController"> 
 
      <div ng-repeat="tag in tagsByType.Tags" class="tag label label-success"> 
 
       {{tag.Title}} 
 
       <a class="close" href ng-click="removeTag(tag)">×</a> 
 
            
 
      </div> 
 
      <form ng-submit="saveTag(Title,tagsByType.Id)" role="form"> 
 
       <input type="text" ng-model="Title" class="form-control" placeholder="add a tag..." ng-options="suggestion.Title for suggestion in suggestion" uib-typeahead="suggestion.Title for suggestion in loadTags($viewValue,tagsByType.Id)" typeahead-loading="loadingTags" typeahead-no-results="noResults"> 
 
       <span class="input-group-btn"><input type="submit" class="btn btn-default" value="Add"></span> 
 
      </form> 
 
     </div> 
 
    </div> 
 
</div> 
 
</div>

+0

bunu Fixed? – Nico

+0

Bunu da denedim. Ancak tüm sayfayı yenileyene kadar kullanıcı arayüzünü güncellemez. –

cevap

0
aynı özellik adıyla nesne olarak verilerinizi itin

.

$scope.saveTag = function (data,TagTypeId) { 
     var result = employeeCvService.addTag(data, TagTypeId, $scope.consultantCv.Id).success(function(data){ 
       var newData = { 
       Title : data, 
       } 
      $scope.consultantCv.TagsbyTypes[0].Tags.push(newData); 
     }); 
     // $scope.consultantCv.TagsbyTypes[0].Tags.push(newtag); //this code is not updating the binding in the UI 
    }; 
+0

Hala çalışmıyor –

0

Sorunun, tagsType'ın denetleyiciye aktarılmadığı bulundu. senin `ng-model`` tag.Title` ve sadece `başlık ile` olmamalı aşağıdaki kodla

$scope.saveTag = function (data,TagTypeId) { 
 
     var result = employeeCvService.addTag(data, TagTypeId, $scope.consultantCv.Id).success(function(result){ 
 
      TagTypeId.Tags.push(result); 
 
      $scope.consultantCv.TagsbyTypes.Tags.push(newData); 
 
      //$scope.consultantCv.TagsbyTypes[0].Tags.push(new1); 
 
     }); 
 
     // $scope.consultantCv.TagsbyTypes[0].Tags.push(newtag); 
 
    };
<form ng-submit="saveTag(tag.Title,tagsByType)" role="form"> 
 
            <input type="text" ng-model="tag.Title" class="form-control" placeholder="add a tag..." ng-options="suggestion.Title for suggestion in suggestion" uib-typeahead="suggestion.Title for suggestion in loadTags($viewValue,tagsByType.Id)" typeahead-loading="loadingTags" typeahead-no-results="noResults"> 
 
            <span class="input-group-btn"><input type="submit" class="btn btn-default" value="Add"></span> 
 
           </form>