How I can retrieve a value from a call with $resoure and use it in JS, no only in my views with data binding?
I have this JSON:
{
"id": 18,
"name": "adsfadsf",
"type_of_dish": "Tacos",
"cost": "5.95",
"notes": "bla bla bla",
"totalrecipes": 1,
"dish_recipes_attributes": [
{
"recipe_id": 28,
"no_recipe": 1,
"name": "tacos al pastor piña",
"cost_portion": "5.95"
}
]
}
in my JS:
$scope.dish = Dish.get({id: $routeParams.id});
I need to get the value "totalrecipes", I've tried with this without successfull:
var totalrecipes = $scope.dish.totalrecipes;
console.log(totalrecipes); //Undefined
console.log($scope.dish); // [object Object]
But in my view everything is ok:
{{dish.totalrecipes}} // 1, It's OK!