Angularjs 在角度模板中使用过滤器显示对象/模型属性无效

Angularjs 在角度模板中使用过滤器显示对象/模型属性无效,angularjs,Angularjs,我有这个: //key has the following format "first.second.third"; //splitString is returning the part after last . {{object.eventMap[key|splitString:'.':-1]}} doesn't work. 这是一个ng重复,所以很难在控制器中单独进行 我做错什么了吗 是的,过滤器不是这样工作的。 在这种情况下,我建议您只需使用以下表达式调用当前作用域中的函数: {{

我有这个:

//key has the following format  "first.second.third";
//splitString is returning the part after last .

{{object.eventMap[key|splitString:'.':-1]}} doesn't work.
这是一个ng重复,所以很难在控制器中单独进行


我做错什么了吗

是的,过滤器不是这样工作的。 在这种情况下,我建议您只需使用以下表达式调用当前作用域中的函数:

{{object.eventMap[figureOutKey(key)]}}

此函数figureOutKey在控制器中定义并返回修改后的密钥。

将筛选器用括号括起来,如下所示:

{{object.eventMap[(key|splitString:'.':-1)]}}
希望这有帮助