Support zoneless applications #416
Replies: 11 comments
-
The directive works fine: <ng-container *transloco="t">
{{ t('HELLO') }}
</ng-container> |
Beta Was this translation helpful? Give feedback.
-
Both calls markForCheck internally, so I don't know why the pipe doesn't work. To me, it seems like an Angular related thing. |
Beta Was this translation helpful? Give feedback.
-
@ArielGueta I would like to use pipe, not directive. Problem is related to pipe. Maybe you are right, and it is not transloco problem but Angular... |
Beta Was this translation helpful? Give feedback.
-
@ArielGueta update: |
Beta Was this translation helpful? Give feedback.
-
Same behavior with ngx-translate lib, demo here: https://stackblitz.com/edit/angular-nuvqxb |
Beta Was this translation helpful? Give feedback.
-
So it doesn't relate to Transloco. There is some weird behavior in stackblitz. I open your blitz and when I press space in the editor it works: |
Beta Was this translation helpful? Give feedback.
-
@ArielGueta |
Beta Was this translation helpful? Give feedback.
-
Hi @emzet currently we are not supporting applications that runs without zone. If you like you can open a pr to support zoneless applications |
Beta Was this translation helpful? Give feedback.
-
Hi @itayod, I think that it is very poor explanation. I appreciate if you can explain why this decision (and what about future?). Is this related to this library or is it issue of Angular itself? How should I open PR to support it, if some other hints how to do that are missing? I studied code of transloco pipe and also ngx pipe, but can not found out where problem can be... maybe some more proactivity from your side... I think it is essential to support Angular application without zone.js, especially in case of Angular Elements, where this zone.js should be omited, when one need to use more Angular Element applications on one website/page |
Beta Was this translation helpful? Give feedback.
-
Oh wow, I know that @ngrx/component is going to enable a lot more apps to opportunity to drop zone. And the lack of Angular Elements without zone. That hurts. |
Beta Was this translation helpful? Give feedback.
-
@emzet, @cgatian, @itayod here is a working example https://stackblitz.com/edit/angular-hbppzv?file=src/app/app.module.ts All the magic is here. This solution was tested on very big application. That app is configured to be zoneless and all is working as expected. The trick is to delay a bit change detection process to prevent races. this.translocoService
.selectTranslation()
.pipe(
delay(0, animationFrameScheduler),
takeUntil(this.destroyed$)
).subscribe(() => this.applicationRef.tick()); |
Beta Was this translation helpful? Give feedback.
-
I'm submitting a...
Current behavior
When used within Angular Element application without zone.js, translation pipe does not work, translations keys are not translated nor visible.
What i tried already:
ChangeDetectorRef.markForCheck()
orChangeDetectorRef.detectChanges()
in various app lifecycles hooksngOnInit, ngAfterViewInit, ngOnChanges
ApplicationRef.tick()
in various app lifecycles hooksngOnInit, ngAfterViewInit, ngOnChanges
ChangeDetectionStrategy
toOnPush
but nothing helps...
Expected behavior
To work transloco as expected i.e. translate keys into texts.
Minimal reproduction of the problem with instructions
'@webcomponents/webcomponentsjs/custom-elements-es5-adapter.js'
insrc\polyfills.ts
'document-register-element'
insrc\polyfills.ts
zone.js
fromsrc\polyfills.ts
{ ngZone: 'noop' }
insrc\main.ts
and here is a demo https://stackblitz.com/edit/angular-xb7xmc
What is the motivation / use case for changing the behavior?
To work transloco translations in Angular Elements (Web Components) applications without zone.js.
Environment
Beta Was this translation helpful? Give feedback.
All reactions