Мне нужно установить язык и направление rtl & ltr.Таким образом, DOCUMENT
вводят в службу, предоставляют службу в модуле ядра.
Наконец-то я получил пакет Bild и импортировал CoreModule
в проект
CoreModule:
this._translateService.addLangs(supportLang);
this._translateService.setDefaultLang(defaultLang);
this._translateService.use(defaultLang).subscribe(res => {
const dir = defaultLang === 'ar' ? 'rtl' : 'ltr';
this._uiService.setDirection(dir);
this._translateService.isCompleted();
});
UiService:
export class UiService {
@NarikInject(DOCUMENT)
document: Document;
@NarikInject(Location)
_location: Location;
setDirection(dir: string) {
this.document.dir = dir;
}
}
@ NarikInject в github
core.js: 6014 ОШИБКА TypeError: Невозможно установить для свойства 'dir' значение null