Mhd Wael Jazmati
Mhd Wael Jazmati

Reputation: 667

Translating String with Variable

I want to Translate a String, with AngularJs filter and here i will put my code :

item={ "_id": "58b9ee5fd7835400059c11f7", "privilegeParent": "58b9ec296aca0e2020257c4a", "create": { "at": "2017-03-05T01:34:28.273Z" }, "notifications": { "web": { "active": false }, "mail": { "active": false }, "sms": { "active": false }, "parameters": [] }, "name": { "code": "systemStatus", "en": "System Status" } }

And here html code :

 <h2 class="md-toolbar-tools"><span>{{::"update_screen"| translate :'{x:item.name.en}'}}</span>
        </h2>

and Here Desired String "update_screen":"Update Screen of {{x}}"

Upvotes: 0

Views: 132

Answers (1)

NiCo C
NiCo C

Reputation: 31

If you're using lodash, in your filter function you can do this:

function myFilter() {
    return function(str, obj) {
        return _.join(['Update screen of ', _.get(str, obj.x)]);   
    }
}

If you're not using any utility library, please provide a little more information

Hope that helps!

Upvotes: 1

Related Questions