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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.