Reputation: 21
I am using angularjs, now i going to add angular-translate library
<jb-sub-header sub-header-label="Match Details"></jb-sub-header>
In above tag jb-sub-header
is the component and sub-header-label
is an attribute, but i dont know how i translate this "match details".
Upvotes: 0
Views: 88
Reputation: 23859
Use the $translate
service, which can easily be injected in your controller. You can assign a translation string as follows in a variable of the scope:
$translate(['YOUR_KEY_HERE']).then(function (translations) {
$scope.subheader = translations['YOUR_KEY_HERE'];
});
This way, $scope.subheader
will have the translated string, which can then be used in the directive as follows:
<jb-sub-header sub-header-label="{{subheader}}"></jb-sub-header>
See the How it works section in this guide.
Upvotes: 1