ngTemplateOutlet: Cannot assign to a reference or variable
Asked Answered
H

0

6

When using ngTemplateOutlet and context:

<ng-container *ngTemplateOutlet="template; context: Context"></ng-container>

The context data:

this.Context = {
        $implicit: this.userName,
        'password': this.password,
        'Login': this.Login,
        'Register': this.Register
    };

can't be bound to a 2 way binding, is this a limitation or am i doing something wrong?

<ng-template let-username #loginpage> 
<TextField class="input" hint="Email" keyboardType="email" [(ngModel)]="username"></TextField> 
</ng-template>

I am getting this error:

ns-renderer: Cannot assign to a reference or variable!

Homocyclic answered 2/5, 2017 at 13:52 Comment(5)
Please add more code. Where do you use ngModel?Antilogarithm
I am using it inside the template. As you can see in the modified post.Brigadier
ngModel can't assign to local variables. You can only assign to properties (fields) of your component plnkr.co/edit/xlZgPVU2UQnVg4uoeKvj?p=previewAntilogarithm
Okey, well this doesn't work for me since i am using a component that takes a input: @Input() template: TemplateRef<any>; so i can't access the public variable from the Context. Like this: <login [template]="loginpage" (login)="Login($event)"></login>Brigadier
I've similar problem, i reproduce it angular-hhxgth.stackblitz.ioAvestan

© 2022 - 2024 — McMap. All rights reserved.