2016-03-30 16 views
-1

API'dan aldığım verilerden bir dizi oluşturmak için hedefleme yapıyorum. Ancak bana cannot read property 'push' of undefined Javascript hatasını gösteriyor.Özellik 'unatfined' push 'okunamıyor AngularJS

Bana bir çıkış yolu işaret edebilir mi? Eğer birkaç yerde kaynak mispelled

myService.getData().then(function (res) { 
      $scope.resoureceGroupsRawData = res.data; 
      //declare an array already... 
      $scope.resourceGroupItems = new Array(); 

     }, function(error) { 
      throw error; 
     }).then(function() { 
      _.forEach($scope.resoureceGroupsRawData, function(text, idx) { 
       var item = {}; 
       item.id = idx++; 
       item.label = text; 
       //why it says resourceGroupItems is null? 
       $scope.resouceGroupItems.push(item); 
      }); 
     }, function(err) { 

     }); 
+0

Hataya sahip olan satırdaki "rsouceGroupItems" ikinci "r" eksik. –

cevap

1

yazım hataları bro, : Burada

kodudur.

myService.getData().then(function (res) { 
      $scope.resourceGroupsRawData = res.data; 
      //declare an array already... 
      $scope.resourceGroupItems = new Array(); 

     }, function(error) { 
      throw error; 
     }).then(function() { 
      _.forEach($scope.resourceGroupsRawData, function(text, idx) { 
       var item = {}; 
       item.id = idx++; 
       item.label = text; 
       //why it says resourceGroupItems is null? 
       $scope.resourceGroupItems.push(item); 
      }); 
     }, function(err) { 
      //TODO need add error page here 
     }); 
+0

hangi yazım hatası ??? belirtebilir misin – catlovespurple

+0

, $ scope.resourceGroupItems = new Array(); olarak bildirirsiniz ve $ scope.resouceGroupItems.push (item); 'olarak kullanılır. bir r' @catlovespurple – arifin4web

+0

cevapsız Doğru olsa da, bu cevap yararlı değildir. Lütfen açıklama ekleyin. –

İlgili konular