components icon indicating copy to clipboard operation
components copied to clipboard

md-icon not rendering when refreshing using hash

Open HeavenlyHost opened this issue 10 years ago • 15 comments

Bug, feature request, or proposal:

When I have a page currently loaded and it is using material 2 icons within an md-icon, e.g.

<md-icon>face</md-icon>

it does load correctly when the page is loaded via the Angular 2 route engine with the following

RouterModule.forRoot(appRoutes, {useHash: true});

url example

localhost:8080/client#mypage

however, refresh via F5 and the icons are no longer displayed, I can get them back if I navigate away and back or if the md-icon lies within a tabgroup, switching tabs and back also then brings them back ???

What is the expected behavior?

md-icon should handle refresh of page via F5 while parent application is using the RouteModule and Hashing

What is the current behavior?

Not rendering icon on page refresh

What are the steps to reproduce?

Create simple app that can navigate to child page with an md-icon via hashing as describes above, hit F5 and notice how the icon is not rendered.

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

Angular 2 Final, Material 2 Alpha 9-3

HeavenlyHost avatar Oct 05 '16 20:10 HeavenlyHost

Hi, can I get some feedback on this please as it is stopping me from using hashing !!!

HeavenlyHost avatar Oct 07 '16 08:10 HeavenlyHost

@jelbourn Many thanks for marking this as required, can I therefore assume that this is agreed to be an issue and if so can I ask about an ETA for completion ? I don't wish to come across as pushy, only my team and I are within a development phase that could really do with this fix ASAP. Many thanks.

HeavenlyHost avatar Oct 08 '16 10:10 HeavenlyHost

I can't reproduce this issue. Works fine using my own sample app (tested on Chrome, Safari and Firefox). Sample url: http://localhost:4200/#/home, which looks different like yours, however is similar to the example of Angular2 doc (localhost:3002/src/#/crisis-center/).

Maybe you can provide your sample app to reproduce the this issue?

chouclee avatar Oct 12 '16 08:10 chouclee

@chouclee I am afraid that the source is sensitive and hence I can't share, however I am quite happy to view a plunker for comparrison, can you point me in the direction of a plunker for Angular 2 material seed (based on v9.3 or above) and I could then go from there.

HeavenlyHost avatar Oct 17 '16 10:10 HeavenlyHost

@HeavenlyHost I cannot reproduce this bug. I've created a sample app with a base href set as '/client/' like yours but icons are correctly displayed after a F5 refresh.

Could you provide a sample app with a simple router config and also provide the way you serve the pages to be accessible to localhost:8080/client (Apache, nginx config...)

feloy avatar Oct 20 '16 08:10 feloy

@feloy what if the base ref were "/" or "" ?

HeavenlyHost avatar Oct 20 '16 10:10 HeavenlyHost

@HeavenlyHost That still works for me with a base href of / or empty.

actimeo avatar Oct 20 '16 10:10 actimeo

My time is quite constrained at the moment, can someone drop me an example of how this is done, as I am not sure I am doing it correctly... Does anyone have a plunker ? Just need to see the code, it does not need to run 😃 many thanks

HeavenlyHost avatar Oct 20 '16 10:10 HeavenlyHost

@HeavenlyHost You can get a repo here https://github.com/feloy/ng2-master-detail and add the useHash to it. Icons are visible in the sidenav.

feloy avatar Oct 20 '16 13:10 feloy

@feloy thanks for providing this example only problem is that you are not implementing the hash strategy as defined by the current Angular Io docs. Your app.routes file should contain the following

RouterModule.forRoot(routes, { useHash: true })

This is how I am doing it and it does not show the icons on refresh ?

HeavenlyHost avatar Oct 20 '16 13:10 HeavenlyHost

@HeavenlyHost I had done it locally.

I've updated the git repo with a new branch with-hash-icon ( https://github.com/feloy/ng2-master-detail/tree/with-hash-icon/ ) and a live demo is available at http://ng2-master-detail-use-hash.surge.sh/

feloy avatar Oct 20 '16 13:10 feloy

@feloy @chouclee @jelbourn Thanks a bunch for getting back to me on this, after doing some more digging I have found that the icons do actually refresh except under the following condition

`

    <li *ngFor="let node of Data"> {{node.myIcon}}

`

This will work if you do this...

`

    <li *ngFor="let node of Data"> home

`

However with the binding to myIcon this is simply not the case, any thoughts ?

HeavenlyHost avatar Oct 20 '16 20:10 HeavenlyHost

@HeavenlyHost it seems the Data is defined after some initialization and that your md-icon is not refreshed afrer data definition. Do you use OnPush as change detection strategy?

feloy avatar Oct 21 '16 19:10 feloy

@feloy thanks so much, you were right the data was not being supplied, it appears that the other data was loaded except the actual icon name. I am satisfied that this is working and can be closed. Thanks again !

HeavenlyHost avatar Oct 23 '16 17:10 HeavenlyHost

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.