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