ng-template

Call a method when ng-template is visible

痴心易碎 提交于 2019-12-24 02:19:10
问题 Does ng-template have any events when it is visible or active in the scope or is it possible to execute any method in such way to call it from the container? <ng-template (active/vissible)="callMethod()"> ... </ng-template> (Or) <ng-container *ngTemplateOutlet="mytemplate" ></ng-container> 回答1: One option could be (valid for any DOM object) is via ViewChildren's QueryList's changes. You mark any DOM element (or use it's type) - <div #myEl></div> Assign it: @ViewChildren('myEl') myEl:

How to display ng-templates from list

为君一笑 提交于 2019-12-22 05:15:14
问题 I have an AppComponent which holds a list of ShapeComponents . I implemented some Components which extends the ShapeComponent like LineComponent , CircleComponent , RectangleComponent . Each of them has its own ng-template with #shapeTemplate . In my app.component.html I want to iterate over the list of ShapeComponents and display each ng-template (from LineComponent , CircleComponent etc). so I have shapes: ShapeComponent[] = [] which hold a LineComponent, CircleComponent etc I want to

How to display ng-templates from list

半腔热情 提交于 2019-12-22 05:15:12
问题 I have an AppComponent which holds a list of ShapeComponents . I implemented some Components which extends the ShapeComponent like LineComponent , CircleComponent , RectangleComponent . Each of them has its own ng-template with #shapeTemplate . In my app.component.html I want to iterate over the list of ShapeComponents and display each ng-template (from LineComponent , CircleComponent etc). so I have shapes: ShapeComponent[] = [] which hold a LineComponent, CircleComponent etc I want to

Angular 4 Dynamic form with nested groups

你离开我真会死。 提交于 2019-12-21 21:52:57
问题 I want to generate a reactive form from the tree structure. Here is the code that creates the form items (form groups and controls). For the controls nested in form group it I use a recursive template. import { Component, Input, NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { FormBuilder, FormGroup, FormsModule, ReactiveFormsModule, Validators } from '@angular/forms'; @Component({ selector: 'form-item', template: ` <ng-container [formGroup]

angular 4 and ng-template

会有一股神秘感。 提交于 2019-12-21 09:15:02
问题 I'm getting this warning: The <template> element is deprecated. Use <ng-template> instead (" [attr.tabIndex]="-1" [ngClass]="{'k-item': true}"> [WARNING ->]<template *ngIf="template" [templateContext]="{ when using angular 4, is this being taken care of for the release version? thanks 回答1: You need to take care of that. You need to modify your code and change all occurences of <template> to <ng-template> <template> caused conflicts with other usages of the <template> tag, therefore the

What is $implicit in angular 2?

谁都会走 提交于 2019-12-18 02:01:50
问题 How is the following keyword used in angular2 ng-templates What is the purpose of $implicit in angular 2 templates? What is relationship between let-<attribute> and $implicit ? 回答1: You can define local variable on ng-template through let-name When angular creates template by calling createEmbeddedView it can also pass context that will be used inside ng-template Using the key $implicit in the context object will set it's value as default. So if we write: vcRef.createEmbeddedView(template, {

Angular ViewChild fileInput annotation is undefined

[亡魂溺海] 提交于 2019-12-12 04:09:34
问题 If my fileInput element is in a normal div, then it works fine. But if I place it inside <ng-template></ng-template> then I am getting it undefined. Here is my code : HTML <ng-template #content let-c="close" let-d="dismiss"> <div class="modal-header"> <h4 class="modal-title">Modal title</h4> <button type="button" class="close" aria-label="Close" (click)="d('Cross click')"></button> </div> <div class="modal-body"> <form #documentsForm="ngForm" (ngSubmit)="onEditSubscriberDocumentsSubmit

How to nest html when looping through array using Angular + ngFor / ng-template?

半腔热情 提交于 2019-12-11 18:26:36
问题 I'm trying to output html in the following format for an array weekDaysHeaderArr whose length is 42 = 6 x 7. In other words I want to nest every 7 column div elements in a row div (6 total) like so. <div class="row"> <div class="col-md-auto"> <-- **repeated 7 times** </div> </div> <div class="row"> <div class="col-md-auto"> <-- **repeated 7 times** </div> </div> <div class="row"> <div class="col-md-auto"> <-- **repeated 7 times** </div> </div> <div class="row"> <div class="col-md-auto"> <-- *

angular2 ng-template in a separate file

﹥>﹥吖頭↗ 提交于 2019-12-10 02:33:01
问题 angular2 how to use ng-template from a different file? When I place the ng-template within the same HTML where I use it works but when I move ng-template into a separate file then it won't work. Is there a way to move ng-template into its own file and use it in different html file? info-message.html <ng-template #messageTemplate> Hi </ng-template> <ng-container *ngTemplateOutlet="messageTemplate;"></ng-container> above is working fine because ng-template and the usage is in same file message

Open ng-bootstrap modal programmatically

喜夏-厌秋 提交于 2019-12-09 08:30:38
问题 I've got an angular 4 page including a ng-bootstrap modal. My code looks like this. foo.html [...] <button class="btn btn-sm btn-secondary material-icons" (click)="open(content)">search</button> <ng-template #content let-c="close" let-d="dismiss"> content in here </ng-template> [...] foo.ts [...] constructor(private modalService: NgbModal) { } [...] open(content) { let options: NgbModalOptions = { size: 'lg' }; this.modalService.open(content, options); } [...] Now when I click the button the