Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/412.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 我可以在$stateProvider.state模板中添加角度过滤器吗?_Javascript_Angularjs - Fatal编程技术网

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