Book Image

Angular Projects

By : Zama Khan Mohammed
Book Image

Angular Projects

By: Zama Khan Mohammed

Overview of this book

<p>Angular is one of the best frameworks, not only for building web applications, but also for building applications on other platforms such as desktop and mobile. It is packed with amazing web tools that allow developers to become more productive and make the development experience a happier one </p><p>This book will be your practical guide when it comes to building optimized web apps using Angular. The book explores a number of popular features, including the experimental Ivy rendered, lazy loading, and differential loading, among others, in the projects. It starts with the basics of Angular and its tools, which will help you to develop and debug Angular applications. You will learn how to create an SPA using Angular Router, and optimize it by code splitting and Preloading Routes. We will then build a form-heavy application and make forms reactive by using Reactive Forms. After that, we will learn how to build a Progressive Web App, and a server-side rendering app, as well as a MonoRepo app. Furthermore, we will also dive into building mobile apps using Ionic and NativeScript. Finally, we end the book by creating a component library for our application using Angular CDK and then testing it. </p><p>By the end of this book, you’ll have gained comprehensive insights into using Angular, along with hands-on experience in creating intuitive real-world applications.</p>
Table of Contents (19 chapters)
Title Page
Copyright and Credits
Dedication
Foreword

Transferring state from the server to the client

Since we are using HttpClient to get posts from the server, one potential problem that could occur in server-rendered, client-side applications is that the API is called twice, once on the server and once in the client. You can check that in the Network tab of the developer tools. Observe the screenshots in the Network tab; you will see that, at 630 ms and 747 ms, the content was available on the page, and then all of a sudden at 1.21 s and 2.03 s, the content was removed and comes back at 2.35 s onward. This happens because, at 630 s, we got data in HTML format from the server, and at 1.21 s, Angular became bootstrapped and called the /posts API:

To overcome this issue, we use TransferStateModule, which allows us to cache any data when the code runs on the server and use that cached data instead of calling the API. First,...