I'm trying to access vue instance data inside filter function like this. 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 goal is to use return amount * this.exchangeRate; but this is equal to window here.
How can I do this ?
Thanks.
jsfiddle