question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ng-template not working in angular 9 with IVY

See original GitHub issue

🐞 bug report

ng-template is not working properly in angular 9 but working fine in angular 8

Is this a regression?

yes, working fine in angular 8

Description

I have created same application in both angular 8 and angular 9, my application working fine in angular 8.

πŸ”¬ Minimal Reproduction

Working sample

  1. download below angular 8 sample angular8.zip

  2. Give β€œnpm i” and β€œng serve”

3.then chose any one row from grid and click β€œedit” button, you wiill see below

image

my template working fine.

issue sample

  1. download below angular 9 sample

angular 9.zip

  1. Give β€œnpm i” and β€œng serve”

3.then below screen occurs , then chose any one row from grid and click β€œedit” button, you wiill see below

image

Code snippet

<ejs-grid [dataSource]='data' allowPaging='true' [pageSettings]='pageSettings' [editSettings]='editSettings' [toolbar]='toolbar' (actionBegin)='actionBegin($event)' (actionComplete)='actionComplete($event)'>
      <e-columns>
          <e-column field='OrderID' headerText='Order ID' width='120' textAlign='Right' [isPrimaryKey]='true'></e-column>
          <e-column field='CustomerName' headerText='Customer Name' width='120'></e-column>
          <e-column field='Freight' headerText='Freight' width='120' format='C2' textAlign='Right'></e-column>
          <e-column field='OrderDate' headerText='Order Date' width='130' format='yMd' textAlign='Right'></e-column>
          <e-column field='ShipCountry' headerText='Ship Country' width='150'></e-column>
      </e-columns>
      <ng-template #editSettingsTemplate let-data>
          <div ngForm #orderForm="ngForm">
              <table class="e-table e-inline-edit" cellspacing="0.25">
                  <colgroup>`
                          <col style="width: 120px;">
                          <col style="width: 120px;">
                          <col style="width: 120px;">
                          <col style="width: 130px;">
                          <col style="width: 150px;">
                  </colgroup>
                  <tbody>
                      <tr>
                          <td style="text-align: right" class='e-rowcell'>
                              <div class="e-input-group" [ngClass]= "{'e-disabled': !data.isAdd}">
                                  <input class="e-input e-field" [(ngModel)]="orderData.OrderID" required [attr.disabled]="!data.isAdd ? '' : null" name='OrderID' type="text" (focus)="focusIn($event.target)"
                                      (blur)="focusOut($event.target)" #OrderID style="text-align: right"  />
                              </div>
                          </td>
                          <td class='e-rowcell'>
                              <div class="e-input-group">
                                  <input class="e-input e-field" name='CustomerName' [(ngModel)]="orderData.CustomerName" required type="text" (focus)="focusIn($event.target)"
                                      (blur)="focusOut($event.target)" #CustomerName />
                              </div>
                          </td>
                          <td style="text-align: right" class='e-rowcell'>
                              <ejs-numerictextbox name="Freight" id="Freight" [(ngModel)]="orderData.Freight" floatLabelType='Never'></ejs-numerictextbox>
                          </td>
                          <td style="text-align: right" class='e-rowcell'>
                              <ejs-datepicker id="OrderDate" name="OrderDate" required [(ngModel)]="orderData.OrderDate" floatLabelType='Never'></ejs-datepicker>                            
                          </td>
                          <td class='e-rowcell'>
                              <ejs-dropdownlist id="ShipCountry" name="ShipCountry" [(ngModel)]="orderData.ShipCountry" [dataSource]='shipCountryDistinctData' [fields]="{text: 'ShipCountry', value: 'ShipCountry' }" popupHeight='300px' floatLabelType='Never'></ejs-dropdownlist>
                          </td>
                      </tr>
                  </tbody>
              </table>
          </div>
      </ng-template>
  </ejs-grid>

🌍 Your Environment

Angular Version:


"@angular/animations": "~9.0.2",
    "@angular/common": "~9.0.2",
    "@angular/compiler": "~9.0.2",
    "@angular/core": "~9.0.2",
    "@angular/forms": "~9.0.2",
    "@angular/platform-browser": "~9.0.2",
    "@angular/platform-browser-dynamic": "~9.0.2",
    "@angular/router": "~9.0.2",
"@angular-devkit/build-angular": "~0.900.3",
    "@angular/cli": "~9.0.3",
    "@angular/compiler-cli": "~9.0.2",
    "@angular/language-service": "~9.0.2",

Anything else relevant? Both angular 8 and angular 9, my template reference are same in my soure level"ngAfterContnctChecked" hook.

angular 8 reference:

image

angular 9 reference:

image

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
bryanridesharkcommented, Mar 31, 2020

@alxhub , we’re going to be merging #35464 and making it possible to override the prototype before startup right? It’ll still be pretty efficient AFAIK, because the read will be cached once the first component of that type has been instantiated.

I think a lot of more advanced users of Angular are waiting with eager expectation for #35464 to be merged.

1reaction
Achilles1515commented, Mar 31, 2020

It’s no longer possible to overwrite lifecycle hooks with mocks on directive instances for testing (instead, modify the lifecycle hook on the directive type itself).

@alxhub But this will be changing β€œsoon”…right? https://github.com/angular/angular/pull/35464

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular Ivy, how a text node points to its ng-template
1 Answer 1 ... const view = component.vcr.createEmbeddedView(component.tpl); /\ || assign to variable expect(view.rootNodes.includes(txtTplEl.
Read more >
Deprecated APIs and features - Angular
However, in practice, Angular ignores two-way bindings to template variables. Starting in version 8, attempting to write to template variables is deprecated. InΒ ......
Read more >
Use <ng-template>. Part 6 of Advanced Angular Component…
Here <ng-container> is used as a placeholder to which you can attach the *ngTemplateOutlet directive, which does all the work. layoutTemplate is the...
Read more >
Angular ng-template, ng-container and ngTemplateOutlet
As we can see, the else clause is pointing to a template, which has the name loading . The name was assigned to...
Read more >
Angular 9's Best Hidden Feature: Strict Template Checking
After upgrading to Angular 9 and its Ivy compiler, we can use a new setting in tsconfig.json for strict template checks. We'll open...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found