Угловой контекст ngTemplateOutlet для визуализации угловых templateRef - PullRequest
0 голосов
/ 20 ноября 2018

Я пытаюсь ввести контекст в ngTemplateOutlet в качестве углового компонента.

Ожидаемый : <div class="WRAPPER"><input [(ngModel)]="firstName" type="text" ></div>

Фактический : <div class="WRAPPER">[object Object]</div>

Возможно ли, что ngTemplateOutlet contextбудет связан с шаблоном ref?https://stackblitz.com/edit/angular-chayhd?file=src%2Fapp%2Fapp.component.ts

@Component({
  selector: 'my-app',
  template: `
      <app-form [wrapper]="angularTemplate"></app-form>
      <ng-template #angularTemplate let-angularTemplate="angularTemplate">
           <div class="WRAPPER">{{angularTemplate}}</div>
      </ng-template>
  `})
export class AppComponent  {}


@Component({
  selector: 'app-form',
  template: `
        <ng-container  *ngTemplateOutlet="wrapper;context {angularTemplate:inputText}" >
        </ng-container>
        <ng-template  #inputText>
             <input  [(ngModel)]="firstName" type="text" >
        </ng-template>
  `})
export class FormComponent  {

  @ContentChild(TemplateRef)
  @Input()
  wrapper: TemplateRef<any>;

  firstName = "John"
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...