I am trying to create a set of custom templates using materials autocomplete and ngTemplateOutlet to switch in which template I want to use to display the results (e.g. if there are grouped results they will display differently to traditional autocomplete options).
ngTemplateOutlet seems to render the template only if there is a default option provided. It seems unable to attach the options directly to the mat-autocomplete without at least one mat-option existing. Ideally, the only options being rendered would be the ones fetched from the component (in a more complicated example, the following code is simple and still replicates the problem). Essentially, I'm looking for a workaround.
I have tried every variation I can think of in terms of ng-container and template.
For example, with a template of
<ng-template #default let-options="options">
<mat-option *ngFor="let option of options" [value]="option">
{{option}}
</mat-option>
</ng-template>
This doesn't render any autocomplete options
<mat-autocomplete #auto="matAutocomplete">
<ng-container *ngTemplateOutlet="default; context:{options: options}"></ng-container>
</mat-autocomplete>
But, with the inclusion of at least one mat-option, this renders all of them
<mat-autocomplete #auto="matAutocomplete">
<mat-option>Test</mat-option>
<ng-container *ngTemplateOutlet="default; context:{options: options}"></ng-container>
</mat-autocomplete>
Here's a stackblitz: https://stackblitz.com/edit/angular-bz45ae?file=app/autocomplete-simple-example.html