What is the proper way of substituting value obtained from json
var app = angular.module('plunker', []);
app.factory('myData', ['$http', function($http) {
return {
get: function() {
return $http.get('data.json').then(function(response) {
return response.data;
});
}
};
}]);
app.controller('MainCtrl', ['$scope', '$http', 'myData', function($scope, $http, myData) {
myData.get().then(function(data) {
$scope.data = data; //this is fine
$scope.Monday= Object.keys($scope.data.day.weekday.Monday.mac_id)
$scope.Tuesday= Object.keys($scope.data.day.weekday.Tuesday.mac_id)
$scope.Wednesday= Object.keys($scope.data.day.weekday.Wednesday.mac_id)
console.log($scope.data );
});
}]);
i wanted to show all keys of macid obtained from json, i used Object.keys($scope.data.day.weekday.Monday.mac_id)
Is there a better approach to get the data instead of parsing data separately for monday, tuesday, wednesday...etc. I believe the way I'm doing is not effective
My plunker link http://plnkr.co/edit/9P9oGgLCuSgivmvbNN2e?p=preview
Thanks in advance
Any help is appreciated