1
Guys, I have the following problem:
I have a json file, and I’m making his call like this:
$http.get("../templates/teste.json").success(function (response) {
$scope.x = response;
});
On my route, it’s like this:
.state('app.detalhe', {
url: '/produtos/:ProdutoId',
views: {
'menuContent': {
templateUrl: 'templates/detalhe.html',
controller: 'ProdutosCtrl'
}
}
})
On my controller, it’s like this:
$scope.produtoSingle = function () {
x[$stateParams.produtoId]; }
}
The url is sending correct:
And he just doesn’t give me back any details, someone would tell me what’s going on?
Fixing: x[$stateParams.productId]; }
– Vinicius Magalhães
productId instead of fruitId? You can edit your post, I’ll fix it for you. How’s your JSON file?
– Giancarlo Abel Giulian
Yes, I will produce instead of fruitId. My json is like this:
– Vinicius Magalhães
[ { "title":"Title", "Subtitle":"Lorem ipsum", }, { "title":"Title 2", "Subtitle":"Lorem ipsum 2", }, { "title":"Title 3", "Subtitle":"Lorem ipsum 3", }
";]
– Vinicius Magalhães
you defined the
$stateParams
in thecontroller
? your$stateParams.produtoId
is syntax different from the parameter on the router, which isProdutoId
. Anything if unsolved, update with your full controller (or at least startup) to check.– celsomtrindade
that key after array
x[ ... ];
is left over... besides the "x" isthis.x
– Ivan Ferrer