2015-09-07 83 views
2

我有一个“国家”的对象,我传递的把手上下文的一部分:查找助手在车把

{ 
'hk': {'name': 'Hong Kong', 'someotherprop': 'someothervalue'}, 
'us': {'name': 'United States', 'someotherprop': 'yetanothervalue'}, 
... 
} 

我想使用查找车把助手从COUNTRYCODE“香港”名义'找香港'。

我可以使用下面的把手指令

{{lookup ../countries countrycode}} 

得到以下对象

{'name': 'Hong Kong', 'someotherprop': 'someothervalue'} 

但我现在该如何提取此对象的name属性?

回答

5

显然,一个能链查找调用使用的子表达式语法

{{lookup (lookup ../countries countrycode) 'name'}} 
+1

而且,如果你需要访问多个属性,例如'name'和'someotherprop',你可以使用'{{#with(lookup ../countries countrycode)}} {{name}} {{someotherprop}} {{/ with}}'http://stackoverflow.com /一个/1487413分之42520682 –