Prerendering with Angular 17 and viewing prerendered results?

610 views Asked by At

I'm trying to get a better understanding of how prerendering with Angular 17 works under the hood. I just tried it out and wrote and article about how to get it to work.

https://fireflysemantics.medium.com/creating-an-angular-application-with-route-prerendering-39d6cd4df22a

And I see the routes being prerendered in dist/ssr/browser. However when looking inside any of the static index.html pages, there's no visible data.

For example the page for the product/bronco looks like this:

<!DOCTYPE html><html lang="en" data-critters-container><head>
  <meta charset="utf-8">
  <title>Ssr</title>
  <base href="/">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" type="image/x-icon" href="favicon.ico">
<link rel="stylesheet" href="styles-5INURTSO.css"></head>
<body><!--nghm-->
  <app-root _nghost-ng-c3984273398 ng-version="17.0.6" ngh="0" ng-server-context="ssg"><router-outlet _ngcontent-ng-c3984273398></router-outlet><!----></app-root>
<script src="polyfills-LZBJRJJE.js" type="module"></script><script src="main-EEDU2CCN.js" type="module"></script>

<script id="ng-state" type="application/json">{"__nghData__":[{"c":{"0":[]}}]}</script></body></html>

So I'm guessing the data is loaded with the module script:

</script><script src="main-EEDU2CCN.js" type="module"></script>

And just wanted to confirm?

1

There are 1 answers

2
Matthieu Riegler On BEST ANSWER

your issue is kind-of expected.

You're prerendering /products/Bronco but the router is configured to match 'product/:id' (notice the missing s).