metahamza
metahamza

Reputation: 1465

back button on Angular2 is broken

UPDATED **

I'm writing my first Angular2 app using routing. A simple quiz application.

Clicking the back button triggers the problem behavior, the template does not render properly with data from the model.

I have a routing scheme where you can go between a series of questions in a quiz using a URL pattern like /question/:n.

My component implements OnReuse, OnActivate, and CanReuse.

My model is attached to the component via a property.

This Plunker has a simplified version of my app.

You can see that clicking the Next button goes to the next question and updates the URL. Clicking the browser's back button does change the URL back, but the template does not actually render.

What am I missing?

Upvotes: 1

Views: 1739

Answers (1)

user2263572
user2263572

Reputation: 5606

If it's a base href issue then it is difficult to diagnose with Plunker. So I am not sure if this is the issue, but please give it a try.

Try changing this:

<script>document.write('<base href="' + document.location + '" />');</script>

To This:

 <base href="/">

within your index.html. If it's already set to to the latter please comment and I will update this response.

Upvotes: 1

Related Questions