javascript - Parse JSON array to object -
i need parse json array object in angular, if correct got no idea how that. have read few posts, , there many on subject reason can not right.
link json: http://wingfield.vmgdemo.co.za/webapi/view_stock_complete
//js
app.controller('showroom', function($scope, $http) { $http.get('http://wingfield.vmgdemo.co.za/webapi/view_stock_complete'). then(function(response) { $scope.view_stock_complete = response.data; }); });
//html
<div class="container" ng-controller="showroom"> <div><span>variant: {{view_stock_complete.stock_id}}</span></div> </div>
your data array, you'll need loop on them using ng-repeat
, or access first entry using view_stock_complete[0]
(function(){ 'use strict'; angular.module('test', []) .controller('testcontroller', testcontroller); testcontroller.$inject = ['$http']; function testcontroller($http) { var vm = this; vm.data = []; $http.get('http://wingfield.vmgdemo.co.za/webapi/view_stock_complete').then(function(response){ vm.data = response.data; }) } })();
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js"></script> <div ng-app='test' ng-controller='testcontroller tc'> <div ng-show="tc.data.length == 0">loading...</div> <div ng-repeat="car in tc.data"> {{$index + 1}}. {{car.make}} {{car.series}} </div> </div>
Comments
Post a Comment