Kendo-angular: Switch RTL/LTR on production with angular-cli according to variable in global window object

Created on 9 Oct 2017  路  3Comments  路  Source: telerik/kendo-angular

I've an app which is multi-lang using angular-cli, need to be able to switch RTL/LTR on production
I don't know how to dynamically change the RTL/LTR, I've tried this but is not working
let useValue=window['someValue']; // true or false according to active user settings
providers: [
{provide: RTL, useValue: useValue}
]
assigning useValue from a flag from the window object but it doesn't change the output when reloading the page, style keeps RTL always while the value has changed has false,
please provide me with the way of how to do it properly

Question

All 3 comments

Changes to the provided value will not be reflected with useValue.
You need to use a factory provider to dynamically resolve values.

Thanks for your reply,
I added this factory function
export function enableRTL() {
if (window['dirConfig'] && window['dirConfig'].isRtl) {
return RTL;
}
return null;
}
And added
providers: [
{provide: RTL, useFactory: enableRTL}
]
It worked but not sure if this is the best way to do it

That would do it, although the token value should be a boolean.

Please note that this repository is for bug reports only. Please open a support ticket if you'd like assistance with project-specific inquiries.

Was this page helpful?
0 / 5 - 0 ratings