After reading this posts: parse json data in angular controller
Here is my problem
I have a controller like this
(function() {
var SomeController = function($scope, someService, $log, $routeParams, ShareData) {
var colors = function(data) {
$scope.Colors = data;
$scope.result = angular.fromJson(data);
alert($scope.result);
};
var errorDetails = function(serviceResp) {
$scope.Error = "No connection to server";
};
someService.colors().then(colors, errorDetails);
};
app.controller("SomeController", ["$scope", "someService", "$log", "$routeParams", "ShareData", SomeController]);
}());
This alert returns [object Object],[object Object] When I try to parse one property of this object it returns undefined.
Here is the code.
(function() {
var SomeController = function($scope, someService, $log, $routeParams, ShareData) {
var colors = function(data) {
$scope.Colors = data;
//here it returns undefined
$scope.result = angular.fromJson(data);
alert($scope.result[0].path);
};
var errorDetails = function(serviceResp) {
$scope.Error = "No connection to server";
};
someService.colors().then(colors, errorDetails);
};
app.controller("SomeController", ["$scope", "someService", "$log", "$routeParams", "ShareData", SomeController]);
}());
The service is OK and it returns two complex objects which have a property named path.
$scope.result
to look like? Array of paths or something else?