Book Image

Beginning Server-Side Application Development with Angular

By : Bram Borggreve
Book Image

Beginning Server-Side Application Development with Angular

By: Bram Borggreve

Overview of this book

Equip yourself with the skills required to create modern, progressive web applications that load quickly and efficiently. This fast-paced guide to server-side Angular leads you through an example application that uses Angular Universal to render application pages on the server, rather than the client. You'll learn how to serve your users views that load instantly, while reaping all the SEO benefits of improved page indexing. With differences of just 200 milliseconds in performance having a measurable impact on your users, it's more important than ever to get server-side right.
Table of Contents (10 chapters)

Creating the Container Components


In this section, we will use ng generate to create the PostsComponent and ProfileComponent inside the PostsModule, add routes to both components, and add dummy data that we can use to build our presentational components.

Creating PostsComponent and ProfileComponent

We will be using the ng generate command to create our PostsComponent. This is the component that will eventually list an overview for all our posts.

The application route to this component will be /posts:

  1. Open your terminal and navigate to the project directory.

  2. Run the following command from inside the project directory:

    ng g c posts/containers/posts
  3. Open the src/app/posts/posts-routing.module.ts file.

  4. Import the PostsComponent:

    import { PostsComponent } from './containers/posts/posts.component'
  5. Add the following route to the routes array:

    { path: '', component: PostsComponent },

Now when we refresh the page in our app, we should see the text posts works! between our header and footer:

Very similar to how...