ngModel in ng-template dialog

2.3k Views Asked by At

In my Angular 5 controller HTML I've got a simple ng-template that has a form in it, and the input elements have an ngModel binding. The modal form for that template is just displayed via a button event like so:

openModal(template: TemplateRef<any>) {
    this.modalRef = this.modalService.show(template);
}

When I click a button on the form, and it calls my (click) handler, I'm not sure how to access those bound values as they don't seem to bind to the current controller.

So the template has something like this:

<input type="text" name="ar" id="ar" class="form-control" ([ngModel])="ar" required>

But this.ar is always undefined in the controller.

0

There are 0 best solutions below