0
私はAngularJsで新しく、2種類のJSON返信サービスからデータを取得しようとしています。
私はユーザーIDを表示している1つのサービスから取得したリストを持っています。
これはうまくいっていますが、私の必要なのは、そのユーザーIDが与えられれば、他のJSONからユーザーの名と姓を取得することです。
どうすればいいですか?どんな助けも歓迎です。1つのサービスからIDを取得すると、AngularJSを使用して他のJSONからデータを取得します
これはAngularJs(1.6)コントローラです:
controller('myReservations',function($scope,$http){
$scope.reserve = [];
$scope.sId = s;
$http.get('/reserve/').then(
function(response){
$scope.reserve = response.data.description;
},
function(response){
console.log(response.statusText);
}
);
})
そしてHTML:
<ul class="reservationsList" ng-controller="myReservations">
<li ng-repeat="res in reserve | filter: {ideventroom: sId}">
User: {{res.iduser}} <br>
First name: <!-- Here goes the first name --><br>
Last name: <!-- Here goes the last name -->
</li>
</ul>
とサービスには、以下のJSONを戻ってきています。
では "/準備/" 私が手: "/ユーザー/ 2" では
{
"status": 0,
"description": [
{
"id": 1,
"ideventroom": 3,
"iduser": 2
},
{
"id": 2,
"ideventroom": 3,
"iduser": 1
}
]
}
を私が取得:
{
"status": 0,
"description": [
{
"id": 2,
"firstname": "John",
"lastname": "Smith",
"email": "[email protected]",
"phone": "11111111"
}
]
}
ありがとうございました!