0
私はangularjs 1.6とui-routerを使用しています。ui-routerはコールバック内で複数の値を解決します
残りのAPIからのデータを解決して、ui-router状態のコンポーネントにバインドします。以下のコードは動作しますが、サーバはヘッダ 'X-Total-Count'も返すので、コンポーネントにバインドする必要があります。
このリクエストで返されたヘッダーにアクセスして、他の解決済みの値を設定するにはどうすればよいですか?
UI-ルータの状態:
$stateProvider.state({
name: 'customers',
url: '/customers?page&query',
component: 'customerTable',
resolve: {
customers: function(Customer, $stateParams) {
// a lot of code here to set the filter...
return Customer.find({filter: filter})
.$promise
.then(
function(res) {
return res;
}
);
},
totalCount: function() {
// How can I set this from the response returned above?
}
}
});
とコンポーネント:また
.component('customerTable', {
templateUrl: 'customer-table.html',
controller: CustomerTableCtrl,
bindings: {
customers: '<',
totalCount: '<'
}
})
、私は、サーバー上のループバック3を使用しています。ありがとう