components icon indicating copy to clipboard operation
components copied to clipboard

bug(data-table): data source connect not called when using router

Open benb7760 opened this issue 9 years ago • 9 comments

Bug, feature request, or proposal:

I have copied the exact demo from 'material-examples' into a plunker and have loaded the TableBasicExample component via a router. When navigating to the router (via button in toolbar on plunkr), the table does not display correctly. When clicking that button again, it works. In my own application I have tested by including logging in the connect() method of the data source. It does not get called on initial navigation to the route, but it does when you navigate the second time

One resolution I have used is to perform the dataSource initialization in a setTimeout(1), which solves the issue, but I do not believe that this should be the solution.

What is the expected behavior?

The data source connect method should be called after navigating to page via router

What is the current behavior?

The data source connect method is not called

What are the steps to reproduce?

http://plnkr.co/edit/RRVoUV9SBAxozY6VhvpA?p=preview

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

latest master, and beta8

benb7760 avatar Jul 07 '17 22:07 benb7760

same for me

fiste788 avatar Jul 08 '17 15:07 fiste788

Same here.

When calling changeDetector.detectChanges after setting the DataSource to manually trigger ChangeDetection the Table will show up.

http://plnkr.co/edit/Soc0n4ak80VKdZ27htVU?p=preview

xbtequila avatar Jul 10 '17 07:07 xbtequila

Same here. The workaround with changeDetector.detectChanges also works for me, but is not satisfying.

AppField avatar Jul 10 '17 20:07 AppField

Same here

niceilm avatar Jul 17 '17 01:07 niceilm

Same for me !

houabidi avatar Aug 23 '17 09:08 houabidi

How is this Issue closed? I mean it does have a workaround that somehow works, but the issue itself is not fixed. At least the workaround should be mentioned on the documentation. ---- Edit Ooops its merged, forget it.

Potmos avatar Aug 24 '17 20:08 Potmos

Lost so much time figuring this out... =(

I also tried to use snapshot builds but it was not working either.

The detectChanges works but let's hope beta 9 is available with a fix soon :)

maxime1992 avatar Aug 27 '17 09:08 maxime1992

I can confirm this hack is not necessary anymore with beta10.

Toub avatar Sep 14 '17 07:09 Toub

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.