Getting:
TypeError: a is undefined...


On Thursday, October 23, 2014 8:39:17 AM UTC-5, Adrian Lynch wrote:
>
> Array.concat joins two or more arrays. It's not a problem with Angular, 
> just straight-up JS.
>
> So regarding:
>
> *var newlist = oldtags.concat(newtags);*
>
>
> If oldtags is an array of strings and newtags is an array of objects, you 
> can't just concat them if you want them to be the same.
>
> *var newlist = oldtags.concat(newtags.map(function(item) { return 
> item.text; }));*
>
>
> Untested but give it a try!
>
> Adrian
>
>
> On 23 October 2014 14:19, Ren Vile <[email protected] <javascript:>> 
> wrote:
>
>> I would like to combine two JSON objects in Angular but I don't know 
>> enough about angular to understand what I'm doing wrong.  I've searched for 
>> hours already and can't seem to progress any further.  Please see code and 
>> pictures below to see what my results are.
>>
>>
>>    - Essentially I'm trying to concatenate two different models into 
>>    one. 
>>    - On the first pass it adds 3 models from JSON.
>>    - On the second pass it will add one more model (XL-Z232) but this is 
>>    where it doesn't function correctly.
>>    
>>
>> But when I combine them the joined array shows as and Object array with a 
>> Standard Array.  Please take a look!
>>
>>    
>>  var oldtags;
>>     var newtags;
>>
>>     $scope.getModels = function () {
>>
>>         if ($scope.tags.length > 0) {
>>
>>             $http.post('../../../ProductWS.asmx/FetchModelsList', { 
>> 'make': 'MYMAKE', 'category': 'audio', 'subcategory': 'cd player', 'year'
>> : '1999' })
>>             .success(function (data, status, headers, config) {
>>                
>>                 newtags = data.d;                
>>             }).
>>             error(function (data, status, headers, config) {
>>                 // log error
>>             }).then(function (results) {    
>>                       
>>                 var newlist = oldtags.concat(newtags);
>>              
>>                 $scope.tags = newlist;
>>                 console.log(newlist);
>>
>>
>>                 //});
>>                 });
>>
>>
>>         }
>>         else {
>>             $http.post('../../../ProductWS.asmx/FetchModelsList', { 
>> 'make': 'MyMake', 'category': 'video', 'subcategory': 'Blu Ray Player', 
>> 'year': '2012' })
>>             .success(function (data, status, headers, config) {
>>                 $scope.tags = data.d;
>>                 oldtags = $scope.tags;
>>                 console.log(oldtags);
>>
>>             }).
>>             error(function (data, status, headers, config) {
>>                 // log error
>>             });
>>         }
>>
>>     };
>>
>>
>>
>>
>>
>> <https://lh6.googleusercontent.com/-CVrEdj1A8sk/VEj-5Rn0dRI/AAAAAAAAABU/5byQl9pd0jQ/s1600/models.png>
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "AngularJS" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> Visit this group at http://groups.google.com/group/angular.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to