我有一个 Angular 工厂DogePrice
:
.factory('DogePrice', ['$resource', function ($resource) {
return $resource("https://chain.so/api/v2/get_info/DOGE");
}])
典型的 api 响应是这样的:
{
"status" : "success",
"data" : {
"name" : "Dogecoin",
"acronym" : "DOGE",
"network" : "DOGE",
"symbol_htmlcode" : "Ð",
"url" : "http://www.dogecoin.com/",
"mining_difficulty" : "18661.80200222",
"unconfirmed_txs" : 7,
"blocks" : 1119625,
"price" : "0.00000046",
"price_base" : "BTC",
"price_update_time" : 1453938374,
"hashrate" : "1289658619826"
}
}
如何创建只返回data.price
字段的工厂?我想要一个干净的控制器,只有$scope.price = DogePrice.get();
或类似的东西。