Javascript 我可以在$stateProvider.state模板中添加角度过滤器吗?
我知道我可以添加如下货币过滤器:Javascript 我可以在$stateProvider.state模板中添加角度过滤器吗?,javascript,angularjs,Javascript,Angularjs,我知道我可以添加如下货币过滤器: {{amount | currency}} 然而,我正在生成动态状态,因此我正在创建内联模板。所以我想知道我是否可以像这样在我的动态状态中添加一个货币过滤器: data.items.forEach(function(item, index){ if(item.type === 'yearlyAmount'){ $stateProvider.state(item.alias, { url: '/' + item.title,
{{amount | currency}}
然而,我正在生成动态状态,因此我正在创建内联模板。所以我想知道我是否可以像这样在我的动态状态中添加一个货币过滤器:
data.items.forEach(function(item, index){
if(item.type === 'yearlyAmount'){
$stateProvider.state(item.alias, {
url: '/' + item.title,
template: '<h3>This item made : ' + item.amount (CONVERT item.amount TO CURRENCY) + '</h3>'
}
}
}
这可能吗 是的,这是可能的。将$filter引用到您的模块依赖项,然后执行$filter'currency'item.amount 或者您可以将过滤器存储在某个变量中,比如让currencyFilter=$filter'currency';并在需要时将其用作currencyFilteritem.amount