0

Iam using Angular project from Sahil Malik's blog Use SPFx with Angular and Angular CLI as a startup solution/project....

And i implemented "@angular/router" for routing with some test pages. enter image description here

Just for testing purpose i added some dummy data and html table for rendering the data on page1. But for some reason data never get rendered by *ngFor and in console i can see that there are 5 items in array. enter image description here

For testing further i added same code in "app.component.ts" and "app.component.html" instead. And for some reason *ngFor works fine, table get rendered. But Why dosent it work on page1 ?!

By debugging in chrome i can see that table are rendered in html for "app.component.html", but table on page1 is not rendered or displaying...?! enter image description here

It appears that there is something missing on page1 that makes ngFor not rendering the data on page. Here is html code snippit from chrome debub console: enter image description here

Here is my github repo for testing the solution...

Any help will be appriciated...Thanks...

0

Hello according to your github repo

You are missing to import Page1Component in appmodule.ts. register your page1 component in appmodule.ts like:

import { Page1Component   } from './Page1/Page1Component';

And in declaration in @NgModule

@NgModule({
 declarations: [
AppComponent,
Page1Component,   
routingComponents
]

Hope will work for you

  • Thanks for answering #Sunil, but did you check "app.route.module.ts" under "app" folder? there i have import Page1Component registered as a route, and "app.route.module.ts" is registered in app.module.ts file....so all of my pages are registered in app.route.module.ts....! In my app.module.ts i have under declarations: routingComponents... – user3629354 Aug 17 '18 at 9:39
  • The import for app.route.module is for referring component that you want to use in routing. Try referring them in app module. – Sunil Sahu Aug 17 '18 at 10:30
  • Oki, i tryied refering all components in app.module.ts file as you explained, but dident help....Still i can see data rendered on app.component.html, table are displaying data, but not on page1.... – user3629354 Aug 17 '18 at 10:45
0

Page1, Page2 and Page 3 are registered under : routingComponents

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.