Mark Mark - 1 year ago 90
Jade Question

Translate a string then pass to ng-click

I have a jade template which contains a list and it calls a method called

when an item is clicked. In the example below, I want the
method to be passed the paramaters "category" and "Jobs" (I'm using Angular Translate and have a translation file with "jobs" mapped to "Jobs"). However, the jade compiler doesn't like that and throws an error sayinf:

Syntax Error: Unexpected token

My code is:

li(ng-click='ctrl.change("category", translate='jobs')')

change(dimensionKey, dimensionName) {

console.log('in the change and arguments are ', arguments);


How can I translate a string then pass to

Answer Source

You can use $filter to translate on javascript directly from your translation string ID. Just call the "translate" filter and pass your translation string parameter. For example:

var translate = this.$filter("translate");
var jobsTranslated= translate('jobs');