[Solved] How to pass changed variable from Child component to Parent component without using @Output?


<random-directive [(ngModel)]='name'></random-directive>

In order to use ngModel you have to import in your module FormsModule from "@angular/forms"

Here is an example plunker I made for you:

https://plnkr.co/edit/AReq0QngbE9130Bd38Qq?p=preview

You can’t use multiple variables with a single ngModel, but you can bind it to an object. If you define in your ts an object like this:

public myObject = { name: 'John', surname: 'Doe' }

Then you can bind multiple inputs to your object properties, like this:

<input [(ngModel)]="myObject.name" />
<input [(ngModel)]="myObject.surname" />

According to your edit you need to use @Input()

In your .ts component declare @Input() binded; and @Input() binded2; at the beginning of you component.

export class RandomDirective {
   @Input() binded;
   @Input() binded2;
}

then you can use

<random-directive [(binded)]=“myVar” [(binded2)]=“myVar2”><random-directive>

4

solved How to pass changed variable from Child component to Parent component without using @Output?