I'm attempting to access the data of a Vue instance within a filter function as shown below. JS:-
new Vue({
data:{
amount: 10,
exchangeRate:50
},
el:"#app",
filters:{
currency: function(amount){
console.log(this);
//return amount * this.exchangeRate;
return amount *50;
}
}
})
HTML:
<div id="app">
{{ amount | currency}}
</div>
My objective is to use
return amount * this.exchangeRate;
, however, in this context, this
refers to window
.
How can I achieve this?
Thanks.
jsfiddle