How to do it...

Let's carry out the following steps to create an asynchronous blog post service:

  1. First, we will import our new service into our PostsModule so that it can be injected into any components in the module that need to use the service. We should also add our routes for our new PostListComponent so that it is the default child component in the router-outlet when navigating to /posts:
...import { BlogPostsService } from "./blog-posts.service";import { PostListComponent } from './post-list/post-list.component';const ROUTES = [{  path: "posts",  component: PostsComponent,  children: [    {      path: "",      component: PostListComponent    },    {      path: ":id",      component: PostComponent    }  ]}];@NgModule({  imports: [    ...    RouterModule.forChild(ROUTES) ], ...

Get MEAN Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.