我试图将我从GET API获得的ID
传递给另一个GET API url,这将在另一个州需要。
我有来自GET API的回复
[{
"ID" : 1,
"Name":"XYZ"
}]
我在View中使用了Bootstrap卡,我在ng-repeat中生成以上信息。点击一个特定的卡片,该卡片将通过传递该特定卡片的ID来重定向到其他状态,并带有来自另一个API的信息。例如:http://url/1
。这个网址也是GET。
我是新手。我怎么能做到这一点?我已经通过$ stateparams,但真的没有得到它。
会试图帮助你。
我很有趣你正在使用ui-router,在这种情况下你的状态定义应该如下
{
name: 'root',
url: '/:id',
controller:'rootController',
resolve: {
// info then can be injected into 'rootController'
// $stateParams helps you access the :id property in the url
info: ['$stateParams',function($stateParams) {
// you make the second api call here.
return api.getInfo($stateParams.id);
}]
}
}
从中得到的结论是
希望这能指出你正确的方向,干杯!