Professional Documents
Culture Documents
MEAN Stack (Angular 8) Tutorial - Build A Simple Blog CMS
MEAN Stack (Angular 8) Tutorial - Build A Simple Blog CMS
A comprehensive step by step MEAN Stack (Angular 8) tutorial on build a simple Blog CMS (Content
Management System)
In this MEAN Stack (Angular 8) tutorial, we will build a simple blog CMS that can add, edit, delete and view blog post and
category. So, there are two entities or models that required for this simple blog CMS. There only authenticated users that can
access this CMS. After user login, user can do CRUD (create, read, update, delete) operation on post and category models.
Table of Contents:
New Node Express.js App using Express Generator
Install Mongoose.js
Install Passport.js
Add Mongoose Models or Schemas
Add Express Router for Login and Register
Add Secure Express Router for Category CRUD
Add Secure Express Router for Post CRUD
Add Non-Secure Express Router for Front Page
New Angular 8 Web App using Angular CLI
Add Angular 8 Routing and Navigation
Add a custom Angular 8 HttpInterceptor
Add Angular 8 Service (HttpClient, RxJS, Observable)
Add Angular 8 Material and CDK
Add Angular Material Login and Register Components
Add Angular Material Blog Category CRUD Component
Add Angular Material Blog Post CRUD Component
Secure the Components using Angular 8 Route Guard
Add Angular Material Blog Front Page
Run and Test the MEAN Stack (Angular 8) Blog CMS
The following tools, frameworks, and modules are required for this tutorial achievement:
1. Node.js (https://nodejs.org/)
2. MongoDB (https://www.mongodb.com/)
3. Angular 8 (https://angular.io/)
4. Angular CLI (https://cli.angular.io/)
5. Express.js (https://expressjs.com/)
6. Passport.js (https://passportjs.org/)
7. Mongoose.js (https://mongoosejs.com/)
8. CKEditor 4 (https://ckeditor.com/ckeditor-4/)
9. Terminal or Command Line
10. IDE or Text Editor
https://www.djamware.com/post/5d88cb43e7939eec17dc4c89/mean-stack-angular-8-tutorial-build-a-simple-blog-cms 1/48
11/03/2020 MEAN Stack (Angular 8) Tutorial: Build a Simple Blog CMS
Before the move to the main steps of this tutorial, make sure that you have installed Node.js and MongoDB on your machine.
You can check the Node.js version after installing it from the terminal or Node.js command line.
node -v
v10.15.1
npm -v
6.11.3
Go to the newly created blog-cms folder then install all NPM modules.
cd ./blog-cms
npm install
Now, we have this Express.js app structure for the blog-cms app.
To check and sanitize the Express.js app, run this app for the first time.
nodemon
or
npm start
Then you will see this page when open the browser and go to `localhost:3000`.
Install Mongoose.js
We will use Mongoose as the ODM for MongoDB. Mongoose provides a straight-forward, schema-based solution to model your
application data. It includes built-in type casting, validation, query building, business logic hooks and more, out of the box. To
install Mongoose.js and it's required dependencies, type this command.
Next, open and edit `app.js` then declare the Mongoose module.
https://www.djamware.com/post/5d88cb43e7939eec17dc4c89/mean-stack-angular-8-tutorial-build-a-simple-blog-cms 2/48
11/03/2020 MEAN Stack (Angular 8) Tutorial: Build a Simple Blog CMS
mongoose.connect('mongodb://localhost/blog-cms', {
promiseLibrary: require('bluebird'),
useNewUrlParser: true,
useUnifiedTopology: true,
useCreateIndex: true
}).then(() => console.log('connection successful'))
.catch((err) => console.error(err));
Now, if you re-run again Express.js server after running MongoDB server or daemon, you will see this information in the console.
[nodemon] 1.18.6
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node ./bin/www`
connection successful
Install Passport.js
We will use Passport.js for authentication or user login. Passport is authentication middleware for Node.js. Extremely flexible
and modular, Passport can be unobtrusively dropped into any Express-based web application. A comprehensive set of
strategies support authentication using a username and password, Facebook, Twitter, and more. To install Passport.js and it's
required dependencies, type this command.
Create a new folder to holds configuration files then add configuration files to `config` folder.
mkdir config
touch config/settings.js
touch config/passport.js
module.exports = {
'secret':'mevnsecure'
};
That file holds a secret code for generating a JWT token. Next, open and edit `config/passport.js` then add these lines of codes.
module.exports = function(passport) {
var opts = {};
opts.jwtFromRequest = ExtractJwt.fromAuthHeaderWithScheme("jwt");
opts.secretOrKey = settings.secret;
passport.use(new JwtStrategy(opts, function(jwt_payload, done) {
User.findOne({id: jwt_payload.id}, function(err, user) {
if (err) {
return done(err, false);
}
if (user) {
done(null, user);
} else {
done(null, false);
}
});
}));
};
This config is used for getting the user by matching JWT token with token get from the client. This configuration needs to
create a User model. Now, Open and edit `app.js` then declare required library for initializing with the server by adding these
lines of requires.
https://www.djamware.com/post/5d88cb43e7939eec17dc4c89/mean-stack-angular-8-tutorial-build-a-simple-blog-cms 3/48
11/03/2020 MEAN Stack (Angular 8) Tutorial: Build a Simple Blog CMS
Declare a variable for Authentication, Category, and Post route.
Initialize passport by adding this line after the declaration of app variable.
app.use(passport.initialize());
Add API route to the endpoint URL after other `use` function.
app.use('/api/auth', auth);
app.use('/api/category', category);
app.use('/api/post', post);
mkdir models
touch models/User.js
touch models/Category.js
touch models/Post.js
Open and edit `models/User.js` then add these codes of the required Username and Password fields. Also, password encryption
using Bcrypt and compare password that saved in the MongoDB collection and encrypted plain password from the request
body.
https://www.djamware.com/post/5d88cb43e7939eec17dc4c89/mean-stack-angular-8-tutorial-build-a-simple-blog-cms 4/48
11/03/2020 MEAN Stack (Angular 8) Tutorial: Build a Simple Blog CMS
Next, open and edit `models/Category.js` then add these Javascript codes of the required fields for the category.
Next, open and edit `models/Post.js` then add these Javascript codes of the required fields for the article post including a
reference from the Category collection.
touch routes/auth.js
Open and edit `routes/auth.js` then declares all require variables of Mongoose models, Passport.js, JWT, Express Router, and
Configuration file.
Create a router to register the new user using just a username and password.
https://www.djamware.com/post/5d88cb43e7939eec17dc4c89/mean-stack-angular-8-tutorial-build-a-simple-blog-cms 5/48
11/03/2020 MEAN Stack (Angular 8) Tutorial: Build a Simple Blog CMS
if (!user) {
res.status(401).send({success: false, msg: 'Authentication failed. User not found.'});
} else {
// check if password matches
user.comparePassword(req.body.password, function (err, isMatch) {
if (isMatch && !err) {
// if user is found and password is right create a token
var token = jwt.sign(user.toJSON(), config.secret);
// return the information including token as JSON
res.json({success: true, token: 'JWT ' + token});
} else {
res.status(401).send({success: false, msg: 'Authentication failed. Wrong password.'});
}
});
}
});
});
module.exports = router;
touch routes/category.js
Open and edit `routes/category.js` then add these required modules of the Mongoose model, Passport.js, JWT, Express Router,
and Configuration file.
https://www.djamware.com/post/5d88cb43e7939eec17dc4c89/mean-stack-angular-8-tutorial-build-a-simple-blog-cms 6/48
11/03/2020 MEAN Stack (Angular 8) Tutorial: Build a Simple Blog CMS
Add a function to get and extract the token from the request headers.
module.exports = router;
touch routes/post.js
https://www.djamware.com/post/5d88cb43e7939eec17dc4c89/mean-stack-angular-8-tutorial-build-a-simple-blog-cms 7/48
11/03/2020 MEAN Stack (Angular 8) Tutorial: Build a Simple Blog CMS
Open and edit `routes/post.js` then add these required modules of the Mongoose model, Passport.js, JWT, Express Router, and
Configuration file.
https://www.djamware.com/post/5d88cb43e7939eec17dc4c89/mean-stack-angular-8-tutorial-build-a-simple-blog-cms 8/48
11/03/2020 MEAN Stack (Angular 8) Tutorial: Build a Simple Blog CMS
Add a function to get and extract the token from the request headers.
module.exports = router;
Next, add these lines of routers to GET category list, post list, and single post by ID.
module.exports = router;
Now, we have the latest version of Angular when this example was written.
https://www.djamware.com/post/5d88cb43e7939eec17dc4c89/mean-stack-angular-8-tutorial-build-a-simple-blog-cms 9/48
11/03/2020 MEAN Stack (Angular 8) Tutorial: Build a Simple Blog CMS
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Package Version
------------------------------------------------------
@angular-devkit/architect 0.803.5
@angular-devkit/core 8.3.5
@angular-devkit/schematics 8.3.5
@schematics/angular 8.3.5
@schematics/update 0.803.5
rxjs 6.4.0
Next, create an Angular 8 web app for this Blog CMS App by typing this command.
ng new client
Answer all questions like below which we will add Angular Routing and use SCSS as a stylesheet.
Next, to sanitize the newly created Angular 8 project go to that project folder in the new terminal tab then run the Angular
application.
cd ./client
ng serve
You will this page or view when you open "http://localhost:4200/ (http://localhost:4200/)" in your browser which means the
Angular 8 is ready to go.
ng serve
Open the browser then go to this URL `localhost:4200` and you will see this Angular 8 landing page.
https://www.djamware.com/post/5d88cb43e7939eec17dc4c89/mean-stack-angular-8-tutorial-build-a-simple-blog-cms 10/48
11/03/2020 MEAN Stack (Angular 8) Tutorial: Build a Simple Blog CMS
ng g component auth/login
ng g component auth/register
ng g component home
ng g component admin
ng g component bycategory
ng g component details
ng g component category
ng g component category/category-details
ng g component category/category-add
ng g component category/category-edit
ng g component post
ng g component post/post-details
ng g component post/post-add
ng g component post/post-edit
Open `src/app/app.module.ts` then you will see those components imported and declared in `@NgModule` declarations. Next,
open and edit `src/app/app-routing.module.ts` then add these imports of login, register, home, details, category CRUD, post
CRUD components.
Add these arrays of those components routes to the existing routes constant.
https://www.djamware.com/post/5d88cb43e7939eec17dc4c89/mean-stack-angular-8-tutorial-build-a-simple-blog-cms 11/48
11/03/2020 MEAN Stack (Angular 8) Tutorial: Build a Simple Blog CMS
Open and edit `src/app/app.component.html` and you will see the existing router outlet. Next, modify this HTML page to fit the
CRUD page wrapped by <router-outlet>.
https://www.djamware.com/post/5d88cb43e7939eec17dc4c89/mean-stack-angular-8-tutorial-build-a-simple-blog-cms 12/48
11/03/2020 MEAN Stack (Angular 8) Tutorial: Build a Simple Blog CMS
<div class="container">
<router-outlet></router-outlet>
</div>
Open and edit `src/app/app.component.scss` then replace all SCSS codes with this.
.container {
padding: 20px;
}
@Injectable()
export class TokenInterceptor implements HttpInterceptor {
https://www.djamware.com/post/5d88cb43e7939eec17dc4c89/mean-stack-angular-8-tutorial-build-a-simple-blog-cms 13/48
11/03/2020 MEAN Stack (Angular 8) Tutorial: Build a Simple Blog CMS
Next, we have to register this custom HttpInterceptor and HttpClientModule. Open and edit `client/src/app.module.ts` then add
these imports of HTTP_INTERCEPTORS, HttpClientModule, and TokenInterceptor.
imports: [
BrowserModule,
AppRoutingModule,
HttpClientModule
],
providers: [
{
provide: HTTP_INTERCEPTORS,
useClass: TokenInterceptor,
multi: true
}
],
Now, the HTTP interceptor is ready to intercept any request to the API.
ng g service auth
ng g service home
ng g service category
ng g service post
Next, open and edit `client/src/app/auth.service.ts` then add these imports of HttpClient, RxJS Observable, of, catchError, and
tap.
https://www.djamware.com/post/5d88cb43e7939eec17dc4c89/mean-stack-angular-8-tutorial-build-a-simple-blog-cms 14/48
11/03/2020 MEAN Stack (Angular 8) Tutorial: Build a Simple Blog CMS
Declare a constant variable as Spring Boot REST API URL after the imports.
Declare the variables before the constructor that will use by Angular 8 Route Guard.
Create all required functions for Login, Logout, Register, and helper functions.
logout(): Observable<any> {
return this.http.post<any>(apiUrl + 'logout', {})
.pipe(
tap(_ => {
this.isLoggedIn.emit(false);
this.loggedInStatus = false;
}),
catchError(this.handleError('logout', []))
);
}
Next, create an object class that represents category data `client/src/app/category/category.ts` then replace all file contents
with these.
Next, create an object class that represents category data `client/src/app/post/post.ts` then replace all file contents with these.
https://www.djamware.com/post/5d88cb43e7939eec17dc4c89/mean-stack-angular-8-tutorial-build-a-simple-blog-cms 15/48
11/03/2020 MEAN Stack (Angular 8) Tutorial: Build a Simple Blog CMS
Next, open and edit `client/src/app/services/home.service.ts` then replace all codes with this REST API call for the home and
details pages.
@Injectable({
providedIn: 'root'
})
export class HomeService {
getCategories(): Observable<Category[]> {
return this.http.get<Category[]>(apiUrl + 'category')
.pipe(
tap(_ => this.log('fetched Categories')),
catchError(this.handleError('getCategories', []))
);
}
getPosts(): Observable<Post[]> {
return this.http.get<Post[]>(apiUrl + 'post')
.pipe(
tap(_ => this.log('fetched Posts')),
catchError(this.handleError('getPosts', []))
);
}
Next, open and edit `client/src/app/services/category.service.ts` then replace all codes with this REST API call for the category
CRUD operation.
https://www.djamware.com/post/5d88cb43e7939eec17dc4c89/mean-stack-angular-8-tutorial-build-a-simple-blog-cms 16/48
11/03/2020 MEAN Stack (Angular 8) Tutorial: Build a Simple Blog CMS
@Injectable({
providedIn: 'root'
})
export class CategoryService {
getCategories(): Observable<Category[]> {
return this.http.get<Category[]>(apiUrl)
.pipe(
tap(_ => this.log('fetched Categories')),
catchError(this.handleError('getCategories', []))
);
}
Next, open and edit `client/src/app/services/post.service.ts` then replace all codes with this REST API call for the post CRUD
operation.
https://www.djamware.com/post/5d88cb43e7939eec17dc4c89/mean-stack-angular-8-tutorial-build-a-simple-blog-cms 17/48
11/03/2020 MEAN Stack (Angular 8) Tutorial: Build a Simple Blog CMS
@Injectable({
providedIn: 'root'
})
export class PostService {
getPosts(): Observable<Post[]> {
return this.http.get<Post[]>(apiUrl)
.pipe(
tap(_ => this.log('fetched Posts')),
catchError(this.handleError('getPosts', []))
);
}
ng add @angular/material
If there are questions like below, just use the default answer.
https://www.djamware.com/post/5d88cb43e7939eec17dc4c89/mean-stack-angular-8-tutorial-build-a-simple-blog-cms 18/48
11/03/2020 MEAN Stack (Angular 8) Tutorial: Build a Simple Blog CMS
We will register all required Angular 8 Material components or modules to `src/app/app.module.ts`. Open and edit that file then
add these imports of required Angular Material Components.
import {
MatInputModule,
MatPaginatorModule,
MatProgressSpinnerModule,
MatSortModule,
MatTableModule,
MatIconModule,
MatButtonModule,
MatCardModule,
MatFormFieldModule,
MatMenuModule,
MatToolbarModule } from '@angular/material';
imports: [
BrowserModule,
AppRoutingModule,
HttpClientModule,
BrowserAnimationsModule,
FormsModule,
ReactiveFormsModule,
MatInputModule,
MatTableModule,
MatPaginatorModule,
MatSortModule,
MatProgressSpinnerModule,
MatIconModule,
MatButtonModule,
MatCardModule,
MatFormFieldModule,
MatMenuModule,
MatToolbarModule
],
loginForm: FormGroup;
username = '';
password = '';
matcher = new MyErrorStateMatcher();
isLoadingResults = false;
ngOnInit() {
this.loginForm = this.formBuilder.group({
'username' : [null, Validators.required],
'password' : [null, Validators.required]
});
}
https://www.djamware.com/post/5d88cb43e7939eec17dc4c89/mean-stack-angular-8-tutorial-build-a-simple-blog-cms 19/48
11/03/2020 MEAN Stack (Angular 8) Tutorial: Build a Simple Blog CMS
Add a function to submit the login form.
onFormSubmit(form: NgForm) {
this.authService.login(form)
.subscribe(res => {
console.log(res);
if (res.token) {
localStorage.setItem('token', res.token);
this.router.navigate(['admin']);
}
}, (err) => {
console.log(err);
});
}
register() {
this.router.navigate(['register']);
}
Add a class that handles the form validation above this class.
Next, open and edit `client/src/app/auth/login/login.component.html` then replace all HTML tags with these.
Next, for register page, open and edit `client/src/app/auth/register/register.component.ts` then replace all Typescript codes
with these.
https://www.djamware.com/post/5d88cb43e7939eec17dc4c89/mean-stack-angular-8-tutorial-build-a-simple-blog-cms 20/48
11/03/2020 MEAN Stack (Angular 8) Tutorial: Build a Simple Blog CMS
@Component({
selector: 'app-register',
templateUrl: './register.component.html',
styleUrls: ['./register.component.scss']
})
export class RegisterComponent implements OnInit {
registerForm: FormGroup;
fullName = '';
username = '';
password = '';
isLoadingResults = false;
matcher = new MyErrorStateMatcher();
ngOnInit() {
this.registerForm = this.formBuilder.group({
fullName : [null, Validators.required],
username : [null, Validators.required],
password : [null, Validators.required]
});
}
onFormSubmit(form: NgForm) {
this.authService.register(form)
.subscribe(res => {
this.router.navigate(['login']);
}, (err) => {
console.log(err);
alert(err.error);
});
}
Next, open and edit `client/src/app/auth/register/register.component.html` then replace all HTML tags with these.
https://www.djamware.com/post/5d88cb43e7939eec17dc4c89/mean-stack-angular-8-tutorial-build-a-simple-blog-cms 21/48
11/03/2020 MEAN Stack (Angular 8) Tutorial: Build a Simple Blog CMS
@Component({
selector: 'app-category',
templateUrl: './category.component.html',
styleUrls: ['./category.component.scss']
})
export class CategoryComponent implements OnInit {
ngOnInit() {
this.api.getCategories()
.subscribe((res: any) => {
this.data = res;
console.log(this.data);
this.isLoadingResults = false;
}, err => {
console.log(err);
this.isLoadingResults = false;
});
}
Next, open and edit `src/app/category/category.component.html` then replace all HTML tags with these Angular Material
components that contain a table to display a list of categories.
https://www.djamware.com/post/5d88cb43e7939eec17dc4c89/mean-stack-angular-8-tutorial-build-a-simple-blog-cms 22/48
11/03/2020 MEAN Stack (Angular 8) Tutorial: Build a Simple Blog CMS
Next, open and edit `src/app/category/category-details/category-details.component.ts` then replace all Typescript codes with
these codes that contain the functions for load a single category by ID and delete a category by ID. The loaded category data
hold put to category type data object.
@Component({
selector: 'app-category-details',
templateUrl: './category-details.component.html',
styleUrls: ['./category-details.component.scss']
})
export class CategoryDetailsComponent implements OnInit {
category: Category = { id: null, catName: '', catDesc: '', catImgUrl: '', catContent: '', updated: null };
isLoadingResults = true;
ngOnInit() {
this.getCategoryDetails(this.route.snapshot.params.id);
}
getCategoryDetails(id: any) {
this.api.getCategory(id)
.subscribe((data: any) => {
this.category = data;
console.log(this.category);
this.isLoadingResults = false;
});
}
deleteCategory(id: any) {
this.isLoadingResults = true;
this.api.deleteCategory(id)
.subscribe(res => {
this.isLoadingResults = false;
this.router.navigate(['/category']);
}, (err) => {
console.log(err);
this.isLoadingResults = false;
}
);
}
Next, open and edit `src/app/category/category-details/category-details.component.html` then replace all HTML tags with
these Angular Material components that contain a card that displays category details.
https://www.djamware.com/post/5d88cb43e7939eec17dc4c89/mean-stack-angular-8-tutorial-build-a-simple-blog-cms 23/48
11/03/2020 MEAN Stack (Angular 8) Tutorial: Build a Simple Blog CMS
For add and edit category form we will need a Rich Text editor. For this, we will install CKEditor that fortunately supported
Angular. To install it simply run this command.
imports: [
...
CKEditorModule,
MatContenteditableModule
],
Next, open and edit `src/app/category/category-add/category-add.component.ts` then replace all Typescript codes with these
codes that contain the Angular Form, FormBuilder, FormGroup, FormControl, FormGroupDirective, Validators,
ErrorStateMatcher, etc. The Angular FormGroup initialize by the FormBuilder then the passed validation form fields can submit
to the REST API.
https://www.djamware.com/post/5d88cb43e7939eec17dc4c89/mean-stack-angular-8-tutorial-build-a-simple-blog-cms 24/48
11/03/2020 MEAN Stack (Angular 8) Tutorial: Build a Simple Blog CMS
@Component({
selector: 'app-category-add',
templateUrl: './category-add.component.html',
styleUrls: ['./category-add.component.scss']
})
export class CategoryAddComponent implements OnInit {
categoryForm: FormGroup;
catName = '';
catDesc = '';
catImgUrl = '';
catContent = '';
isLoadingResults = false;
matcher = new MyErrorStateMatcher();
ngOnInit() {
this.categoryForm = this.formBuilder.group({
catName : [null, Validators.required],
catDesc : [null, Validators.required],
catImgUrl : [null, Validators.required],
catContent : [null, Validators.required]
});
}
onFormSubmit() {
this.isLoadingResults = true;
this.api.addCategory(this.categoryForm.value)
.subscribe((res: any) => {
const id = res._id;
this.isLoadingResults = false;
this.router.navigate(['/category-details', id]);
}, (err: any) => {
console.log(err);
this.isLoadingResults = false;
});
}
Next, open and edit `src/app/category/category-add/category-add.component.html` then replace all HTML tags with these
Angular Material components that contain Angular FormGroup, FormControl, Material Input, Textarea, and Additional CKEditor
4 that previously installs.
https://www.djamware.com/post/5d88cb43e7939eec17dc4c89/mean-stack-angular-8-tutorial-build-a-simple-blog-cms 25/48
11/03/2020 MEAN Stack (Angular 8) Tutorial: Build a Simple Blog CMS
Next, open and edit `src/app/category/category-edit/category-edit.component.ts` then replace all Typescript codes with these
codes that contain the Angular Form, FormBuilder, FormGroup, FormControl, FormGroupDirective, Validators,
ErrorStateMatcher, etc. The Angular FormGroup initialize by the FormBuilder and fill with the category that loaded by getting
category function then the passed validation form fields can submit to the REST API.
https://www.djamware.com/post/5d88cb43e7939eec17dc4c89/mean-stack-angular-8-tutorial-build-a-simple-blog-cms 26/48
11/03/2020 MEAN Stack (Angular 8) Tutorial: Build a Simple Blog CMS
@Component({
selector: 'app-category-edit',
templateUrl: './category-edit.component.html',
styleUrls: ['./category-edit.component.scss']
})
export class CategoryEditComponent implements OnInit {
categoryForm: FormGroup;
id = '';
catName = '';
catDesc = '';
catImgUrl = '';
catContent = '';
updated: Date = null;
isLoadingResults = false;
matcher = new MyErrorStateMatcher();
constructor(private router: Router, private route: ActivatedRoute, private api: CategoryService, private formBuilder: FormBuilder) { }
ngOnInit() {
this.getCategory(this.route.snapshot.params.id);
this.categoryForm = this.formBuilder.group({
catName : [null, Validators.required],
catDesc : [null, Validators.required],
catImgUrl : [null, Validators.required],
catContent : [null, Validators.required]
});
}
getCategory(id: any) {
this.api.getCategory(id).subscribe((data: any) => {
this.id = data.id;
this.categoryForm.setValue({
prod_name: data.prod_name,
prod_desc: data.prod_desc,
prod_price: data.prod_price
});
});
}
onFormSubmit() {
this.isLoadingResults = true;
this.api.updateCategory(this.id, this.categoryForm.value)
.subscribe((res: any) => {
const id = res.id;
this.isLoadingResults = false;
this.router.navigate(['/category-details', id]);
}, (err: any) => {
console.log(err);
this.isLoadingResults = false;
}
);
}
categoryDetails() {
this.router.navigate(['/category-details', this.id]);
}
Next, open and edit `src/app/category/category-edit/category-edit.component.html` then replace all HTML tags with these
Angular Material components that contain Angular FormGroup, FormControl, Material Input, Textarea, and Additional CKEditor
4 that previously installs.
https://www.djamware.com/post/5d88cb43e7939eec17dc4c89/mean-stack-angular-8-tutorial-build-a-simple-blog-cms 27/48
11/03/2020 MEAN Stack (Angular 8) Tutorial: Build a Simple Blog CMS
https://www.djamware.com/post/5d88cb43e7939eec17dc4c89/mean-stack-angular-8-tutorial-build-a-simple-blog-cms 28/48
11/03/2020 MEAN Stack (Angular 8) Tutorial: Build a Simple Blog CMS
@Component({
selector: 'app-post',
templateUrl: './post.component.html',
styleUrls: ['./post.component.scss']
})
export class PostComponent implements OnInit {
ngOnInit() {
this.api.getPosts()
.subscribe((res: any) => {
this.data = res;
console.log(this.data);
this.isLoadingResults = false;
}, err => {
console.log(err);
this.isLoadingResults = false;
});
}
Next, open and edit `src/app/post/post.component.html` then replace all HTML tags with these Angular Material components
that contain a table to display a list of posts.
Next, open and edit `src/app/post/post-details/post-details.component.ts` then replace all Typescript codes with these codes
that contain the functions for load a single post by ID and delete a post by ID. The loaded post data hold put to post type data
object.
https://www.djamware.com/post/5d88cb43e7939eec17dc4c89/mean-stack-angular-8-tutorial-build-a-simple-blog-cms 29/48
11/03/2020 MEAN Stack (Angular 8) Tutorial: Build a Simple Blog CMS
@Component({
selector: 'app-post-details',
templateUrl: './post-details.component.html',
styleUrls: ['./post-details.component.scss']
})
export class PostDetailsComponent implements OnInit {
post: Post = {
category: '',
id: '',
postTitle: '',
postAuthor: '',
postDesc: '',
postContent: '',
postReference: '',
postImgUrl: '',
created: null,
updated: null
};
isLoadingResults = true;
ngOnInit() {
this.getPostDetails(this.route.snapshot.params.id);
}
getPostDetails(id: any) {
this.api.getPost(id)
.subscribe((data: any) => {
this.post = data;
this.post.id = data._id;
console.log(this.post);
this.isLoadingResults = false;
});
}
deletePost(id: any) {
this.isLoadingResults = true;
this.api.deletePost(id)
.subscribe(res => {
this.isLoadingResults = false;
this.router.navigate(['/post']);
}, (err) => {
console.log(err);
this.isLoadingResults = false;
}
);
}
Next, open and edit `src/app/post/post-details/post-details.component.html` then replace all HTML tags with these Angular
Material components that contain a card that displays post details.
https://www.djamware.com/post/5d88cb43e7939eec17dc4c89/mean-stack-angular-8-tutorial-build-a-simple-blog-cms 30/48
11/03/2020 MEAN Stack (Angular 8) Tutorial: Build a Simple Blog CMS
Next, open and edit `src/app/post/post-add/post-add.component.ts` then replace all Typescript codes with these codes that
contain the Angular Form, FormBuilder, FormGroup, FormControl, FormGroupDirective, Validators, ErrorStateMatcher, etc. The
Angular FormGroup initialize by the FormBuilder then the passed validation form fields can submit to the REST API.
https://www.djamware.com/post/5d88cb43e7939eec17dc4c89/mean-stack-angular-8-tutorial-build-a-simple-blog-cms 31/48
11/03/2020 MEAN Stack (Angular 8) Tutorial: Build a Simple Blog CMS
@Component({
selector: 'app-post-add',
templateUrl: './post-add.component.html',
styleUrls: ['./post-add.component.scss']
})
export class PostAddComponent implements OnInit {
postForm: FormGroup;
category = '';
postTitle = '';
postAuthor = '';
postDesc = '';
postContent = '';
postReference = '';
postImgUrl = '';
isLoadingResults = false;
matcher = new MyErrorStateMatcher();
categories: Category[] = [];
constructor(
private router: Router,
private api: PostService,
private catApi: CategoryService,
private formBuilder: FormBuilder) { }
ngOnInit() {
this.getCategories();
this.postForm = this.formBuilder.group({
category : [null, Validators.required],
postTitle : [null, Validators.required],
postAuthor : [null, Validators.required],
postDesc : [null, Validators.required],
postContent : [null, Validators.required],
postReference : [null, Validators.required],
postImgUrl : [null, Validators.required]
});
}
onFormSubmit() {
this.isLoadingResults = true;
this.api.addPost(this.postForm.value)
.subscribe((res: any) => {
const id = res._id;
this.isLoadingResults = false;
this.router.navigate(['/post/details', id]);
}, (err: any) => {
console.log(err);
this.isLoadingResults = false;
});
}
getCategories() {
this.catApi.getCategories()
.subscribe((res: any) => {
this.categories = res;
console.log(this.categories);
this.isLoadingResults = false;
}, err => {
console.log(err);
this.isLoadingResults = false;
});
}
https://www.djamware.com/post/5d88cb43e7939eec17dc4c89/mean-stack-angular-8-tutorial-build-a-simple-blog-cms 32/48
11/03/2020 MEAN Stack (Angular 8) Tutorial: Build a Simple Blog CMS
Next, open and edit `src/app/post/post-add/post-add.component.html` then replace all HTML tags with these Angular Material
components that contain Angular FormGroup, FormControl, Material Input, Textarea, and Additional CKEditor 4 that previously
installs.
Next, open and edit `src/app/post/post-edit/post-edit.component.ts` then replace all Typescript codes with these codes that
contain the Angular Form, FormBuilder, FormGroup, FormControl, FormGroupDirective, Validators, ErrorStateMatcher, etc. The
Angular FormGroup initialize by the FormBuilder and fill with the post that loaded by getting post function then the passed
validation form fields can submit to the REST API.
https://www.djamware.com/post/5d88cb43e7939eec17dc4c89/mean-stack-angular-8-tutorial-build-a-simple-blog-cms 33/48
11/03/2020 MEAN Stack (Angular 8) Tutorial: Build a Simple Blog CMS
@Component({
selector: 'app-post-edit',
templateUrl: './post-edit.component.html',
styleUrls: ['./post-edit.component.scss']
})
export class PostEditComponent implements OnInit {
postForm: FormGroup;
category = '';
id = '';
postTitle = '';
postAuthor = '';
postDesc = '';
postContent = '';
postReference = '';
postImgUrl = '';
updated: Date = null;
isLoadingResults = false;
matcher = new MyErrorStateMatcher();
categories: Category[] = [];
constructor(
private router: Router,
private route: ActivatedRoute,
private api: PostService,
private catApi: CategoryService,
private formBuilder: FormBuilder) { }
ngOnInit() {
this.getCategories();
this.getPost(this.route.snapshot.params.id);
this.postForm = this.formBuilder.group({
postTitle : [null, Validators.required],
postAuthor : [null, Validators.required],
postDesc : [null, Validators.required],
postContent : [null, Validators.required],
postReference : [null, Validators.required],
postImgUrl : [null, Validators.required]
});
}
getPost(id: any) {
this.api.getPost(id).subscribe((data: any) => {
this.id = data.id;
this.postForm.setValue({
postTitle: data.postTitle,
postAuthor: data.postAuthor,
postDesc: data.postDesc,
postContent: data.postContent,
postReference: data.postReference,
postImgUrl: data.postImgUrl
});
});
}
getCategories() {
this.catApi.getCategories()
.subscribe((res: any) => {
this.categories = res;
console.log(this.categories);
this.isLoadingResults = false;
}, err => {
console.log(err);
this.isLoadingResults = false;
});
}
onFormSubmit() {
https://www.djamware.com/post/5d88cb43e7939eec17dc4c89/mean-stack-angular-8-tutorial-build-a-simple-blog-cms 34/48
11/03/2020 MEAN Stack (Angular 8) Tutorial: Build a Simple Blog CMS
this.isLoadingResults = true;
this.api.updatePost(this.id, this.postForm.value)
.subscribe((res: any) => {
const id = res.id;
this.isLoadingResults = false;
this.router.navigate(['/post-details', id]);
}, (err: any) => {
console.log(err);
this.isLoadingResults = false;
}
);
}
postDetails() {
this.router.navigate(['/post-details', this.id]);
}
Next, open and edit `src/app/post/post-edit/post-edit.component.html` then replace all HTML tags with these Angular Material
components that contain Angular FormGroup, FormControl, Material Input, Textarea, and Additional CKEditor 4 that previously
installs.
https://www.djamware.com/post/5d88cb43e7939eec17dc4c89/mean-stack-angular-8-tutorial-build-a-simple-blog-cms 35/48
11/03/2020 MEAN Stack (Angular 8) Tutorial: Build a Simple Blog CMS
Open and edit that file and there are already Angular 8 or Typescript imports of the @angular/router CanActivate,
ActivatedRouteSnapshot, and RouterStateSnapshot. So, just these imports of AuthService and Angular Router.
https://www.djamware.com/post/5d88cb43e7939eec17dc4c89/mean-stack-angular-8-tutorial-build-a-simple-blog-cms 36/48
11/03/2020 MEAN Stack (Angular 8) Tutorial: Build a Simple Blog CMS
canActivate(
next: ActivatedRouteSnapshot,
state: RouterStateSnapshot): boolean {
const url: string = state.url;
return this.checkLogin(url);
}
Add the function to check the login status and redirect to the login page if it's not logged in and redirect to the Guarded page if
it's logged in.
Modify the paths that should be secure, so it will look like this.
https://www.djamware.com/post/5d88cb43e7939eec17dc4c89/mean-stack-angular-8-tutorial-build-a-simple-blog-cms 37/48
11/03/2020 MEAN Stack (Angular 8) Tutorial: Build a Simple Blog CMS
https://www.djamware.com/post/5d88cb43e7939eec17dc4c89/mean-stack-angular-8-tutorial-build-a-simple-blog-cms 38/48
11/03/2020 MEAN Stack (Angular 8) Tutorial: Build a Simple Blog CMS
}
];
Inject that home and auth service to the constructor by adding a constructor if it doesn't exist.
Add these variables that hold the categories array and the status of the logged-in user.
Put the logged-in status check inside the NgOnInit function followed by load categories from the REST API.
ngOnInit() {
this.authService.isLoggedIn.subscribe((status: any) => {
if (status === true) {
this.loginStatus = true;
} else {
this.loginStatus = false;
}
});
this.api.getCategories()
.subscribe((res: any) => {
this.categories = res;
console.log(this.categories);
}, err => {
console.log(err);
});
}
logout() {
this.authService.logout()
.subscribe((res: any) => {
this.router.navigate(['/']);
}, err => {
console.log(err);
});
}
If there's no ngOnInit in this app.component.ts, add the import for it and add implements to the class name.
Next, open and edit `src/app/app.component.html` then replace all of the HTML tags with these.
https://www.djamware.com/post/5d88cb43e7939eec17dc4c89/mean-stack-angular-8-tutorial-build-a-simple-blog-cms 39/48
11/03/2020 MEAN Stack (Angular 8) Tutorial: Build a Simple Blog CMS
<mat-toolbar>
<button mat-button [matMenuTriggerFor]="menu">Menu</button>
<mat-menu #menu="matMenu">
<div *ngIf="loginStatus === false">
<button mat-menu-item [routerLink]="['/']">Home</button>
<button mat-menu-item *ngFor="let cat of categories" [routerLink]="['/bycategory/', cat._id]">{{cat.catName}}</button>
</div>
<div *ngIf="loginStatus === true">
<button mat-menu-item [routerLink]="['/admin']">Home</button>
<button mat-menu-item [routerLink]="['/category']">Category</button>
<button mat-menu-item [routerLink]="['/post']">Post</button>
<button mat-menu-item (click)="logout()">Logout</button>
</div>
</mat-menu>
</mat-toolbar>
<router-outlet></router-outlet>
Next, we will show the list of post on the home page. For that, open and edit `src/app/home/home.component.ts` then replace
all Typescript codes with these codes that contain a function to load post data.
@Component({
selector: 'app-home',
templateUrl: './home.component.html',
styleUrls: ['./home.component.scss']
})
export class HomeComponent implements OnInit {
ngOnInit() {
this.api.getPosts()
.subscribe((res: any) => {
this.posts = res;
console.log(this.posts);
this.isLoadingResults = false;
}, err => {
console.log(err);
this.isLoadingResults = false;
});
}
Next, open and edit `src/app/home/home.component.html` then replace with these HTML tags that contain the Angular
Material component to display the grid of data.
Next, to display the post details, open and edit `src/app/details/details.component.ts` then add these lines of Typescript codes
that contain Post objects variable and the call of REST API to get the Post data by ID.
https://www.djamware.com/post/5d88cb43e7939eec17dc4c89/mean-stack-angular-8-tutorial-build-a-simple-blog-cms 40/48
11/03/2020 MEAN Stack (Angular 8) Tutorial: Build a Simple Blog CMS
@Component({
selector: 'app-details',
templateUrl: './details.component.html',
styleUrls: ['./details.component.scss']
})
export class DetailsComponent implements OnInit {
post: Post = {
category: '',
id: '',
postTitle: '',
postAuthor: '',
postDesc: '',
postContent: '',
postReference: '',
postImgUrl: '',
created: null,
updated: null
};
isLoadingResults = true;
ngOnInit() {
this.getPostDetails(this.route.snapshot.params.id);
}
getPostDetails(id: any) {
this.api.getPost(id)
.subscribe((data: any) => {
this.post = data;
console.log(this.post);
this.isLoadingResults = false;
});
}
Next, open and edit `src/app/details/details.component.html` then replace all HTML tags with these Angular Materials Card
component that contain the post details.
Next, we need to add the page that displays the list of the post by category. This page is the action for the categories menu.
Open and edit `src/app/bycategory/bycategory.component.ts` then replace all Typescript codes with these codes that contain
a function to load post data by category.
https://www.djamware.com/post/5d88cb43e7939eec17dc4c89/mean-stack-angular-8-tutorial-build-a-simple-blog-cms 41/48
11/03/2020 MEAN Stack (Angular 8) Tutorial: Build a Simple Blog CMS
@Component({
selector: 'app-bycategory',
templateUrl: './bycategory.component.html',
styleUrls: ['./bycategory.component.scss']
})
export class BycategoryComponent implements OnInit {
ngOnInit() {
this.route.params.subscribe(params => {
this.getPostsByCategory(this.route.snapshot.params.id);
});
}
getPostsByCategory(id: any) {
this.posts = [];
this.api.getPostsByCategory(id)
.subscribe((res: any) => {
this.posts = res;
console.log(this.posts);
this.isLoadingResults = false;
}, err => {
console.log(err);
this.isLoadingResults = false;
});
}
Next, open and edit `src/app/bycategory/bycategory.component.html` then replace all HTML tags with these Angular Material
Grid component to display the list of the post by category.
Finally, we will adjust the style for all Angular Material component globally by open and edit `src/styles.scss` then add these
lines of SCSS codes.
https://www.djamware.com/post/5d88cb43e7939eec17dc4c89/mean-stack-angular-8-tutorial-build-a-simple-blog-cms 42/48
11/03/2020 MEAN Stack (Angular 8) Tutorial: Build a Simple Blog CMS
.example-container {
position: relative;
padding: 5px;
}
.example-table-container {
position: relative;
max-height: 400px;
overflow: auto;
}
table {
width: 100%;
}
.example-loading-shade {
position: absolute;
top: 0;
left: 0;
bottom: 56px;
right: 0;
background: rgba(0, 0, 0, 0.15);
z-index: 1;
display: flex;
align-items: center;
justify-content: center;
}
.example-rate-limit-reached {
color: #980000;
max-width: 360px;
text-align: center;
}
/* Column Widths */
.mat-column-number,
.mat-column-state {
max-width: 64px;
}
.mat-column-created {
max-width: 124px;
}
.mat-flat-button {
margin: 5px;
}
.example-container {
position: relative;
padding: 5px;
}
.example-form {
min-width: 150px;
max-width: 500px;
width: 100%;
}
.example-full-width {
width: 100%;
}
.example-full-width:nth-last-child(0) {
margin-bottom: 10px;
}
.button-row {
margin: 10px 0;
}
.mat-flat-button {
margin: 5px;
}
https://www.djamware.com/post/5d88cb43e7939eec17dc4c89/mean-stack-angular-8-tutorial-build-a-simple-blog-cms 43/48
11/03/2020 MEAN Stack (Angular 8) Tutorial: Build a Simple Blog CMS
mongod
In the second terminal tab inside the Blog-CMS folder run this command.
nodemon
In the third terminal tab inside the blog-cms/client folder run this command.
ng serve
And here the full demo of the MEAN Stack (Angular 8) tutorial from our YouTube Channel.
That it's, the MEAN Stack (Angular 8) Tutorial: Build a Simple Blog CMS. You can find the full working source codes from our
GitHub (https://github.com/didinj/mean-stack-angular-8-blog-cms.git).
If you don’t want to waste your time design your own front-end or your budget to spend by hiring a web designer then Angular
Templates is the best place to go. So, speed up your front-end web development with premium Angular templates
(https://angular-templates.io?ref=8). Choose your template for your front-end project here (https://angular-templates.io?ref=8).
That just the basic. If you need more deep learning about MEAN Stack, Angular, and Node.js, you can take the following cheap
course:
Master en JavaScript: Aprender JS, jQuery, Angular 8, NodeJS (https://click.linksynergy.com/link?
id=6nYo96*QrJE&offerid=507388.1337000&type=2&murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fmaster-en-
javascript-aprender-js-jquery-angular-nodejs-y-mas%2F)
Angular 8 - Complete Essential Guide (https://click.linksynergy.com/link?
id=6nYo96*QrJE&offerid=507388.2159182&type=2&murl=https%3A%2F%2Fwww.udemy.com%2Fangular-7-complete-
essential-guide%2F)
Learn Angular 8 by creating a simple Full Stack Web App (https://click.linksynergy.com/link?
id=6nYo96*QrJE&offerid=507388.2400782&type=2&murl=https%3A%2F%2Fwww.udemy.com%2Fangular-8%2F)
Angular 5 Bootcamp FastTrack (https://click.linksynergy.com/link?
id=6nYo96*QrJE&offerid=358574.1461406&type=2&murl=https%3A%2F%2Fwww.udemy.com%2Fangular-bootcamp-
fasttrack%2F)
Angular 6 - Soft & Sweet (https://click.linksynergy.com/link?
id=6nYo96*QrJE&offerid=507388.1668070&type=2&murl=https%3A%2F%2Fwww.udemy.com%2Fangular-soft-and-
sweet%2F)
Angular 6 with TypeScript (https://click.linksynergy.com/link?
id=6nYo96*QrJE&offerid=507388.1757238&type=2&murl=https%3A%2F%2Fwww.udemy.com%2Fangular6withtypescript%2F)
Thanks!
Follow
(http://www.facebook.com/djamwarecom)
(http://twitter.com/intent/follow?source=followbutton&variant=1.0&screen_name=djamware)
(http://www.pinterest.com/djamware) (http://www.linkedin.com/in/didin-jamaludin-7a530351)
(http://www.youtube.com/channel/UCtI81hYLh2Ae_45KHkyy0vw?sub_confirmation=1) (https://github.com/didinj)
Previous Article
Build a web app using Nestjs, Fastify, MongoDB and Angular 8
(/post/5d2898430707cc5968d9d57f/build-a-web-app-using-nestjs-fastify-mongodb-and-angular-8)
https://www.djamware.com/post/5d88cb43e7939eec17dc4c89/mean-stack-angular-8-tutorial-build-a-simple-blog-cms 44/48
11/03/2020 MEAN Stack (Angular 8) Tutorial: Build a Simple Blog CMS
Next Article
MEAN Stack Angular 9 Build Realtime CRUD Web App Quickly
(/post/5e50b735525fc968b04a707f/mean-stack-angular-9-build-realtime-crud-web-app-quickly)
Related Articles
MEAN Stack Angular 9 Build Realtime CRUD Web App Quickly (/post/5e50b735525fc968b04a707f/mean-stack-
angular-9-build-realtime-crud-web-app-quickly)
Build a web app using Nestjs, Fastify, MongoDB and Angular 8 (/post/5d2898430707cc5968d9d57f/build-a-web-app-
using-nestjs-fastify-mongodb-and-angular-8)
Node, Express, PostgreSQL, Vue 2 and GraphQL CRUD Web App (/post/5cdc0ba280aca754f7a9d1f4/node-express-
postgresql-vue-2-and-graphql-crud-web-app)
Node, Express, React.js, Graphql and MongoDB CRUD Web Application (/post/5cbd1e9a80aca754f7a9d1f2/node-
express-reactjs-graphql-and-mongodb-crud-web-application)
Node.js, Express.js and Multer Restful API for Image Uploader (/post/5c98220080aca754f7a9d1f0/nodejs-expressjs-
and-multer-restful-api-for-image-uploader)
Node, Express, Angular 7, GraphQL and MongoDB CRUD Web App (/post/5c75d68880aca754f7a9d1ed/node-express-
angular-7-graphql-and-mongodb-crud-web-app)
Secure Node.js, Express.js and PostgreSQL API using Passport.js (/post/5bf94d9a80aca747f4b9ce9f/secure-nodejs-
expressjs-and-postgresql-api-using-passportjs)
Node, Express, Sequelize, and PostgreSQL Association Example (/post/5bb1f05280aca74669894417/node-express-
sequelize-and-postgresql-association-example)
MongoDB, Express, Vue.js 2, Node.js (MEVN) and SocketIO Chat App (/post/5b6a681f80aca76a2cbd98fb/mongodb-
express-vuejs-2-nodejs-mevn-and-socketio-chat-app)
Node.js, Express.js, Sequelize.js and PostgreSQL RESTful API (/post/5b56a6cc80aca707dd4f65a9/nodejs-expressjs-
sequelizejs-and-postgresql-restful-api)
MEAN Stack Angular 6 CRUD Web Application (/post/5b00bb9180aca726dee1fd6d/mean-stack-angular-6-crud-web-
application)
Securing MEVN Stack (Vue.js 2) Web Application using Passport (/post/5ac8338780aca714d19d5b9e/securing-mevn-
stack-vuejs-2-web-application-using-passport)
Securing MERN Stack Web Application using Passport (/post/5a90c37980aca7059c14297a/securing-mern-stack-web-
application-using-passport)
Securing MEAN Stack (Angular 5) Web Application using Passport (/post/5a878b3c80aca7059c142979/securing-
mean-stack-angular-5-web-application-using-passport)
Setup Node.js, Nginx and MongoDB on Ubuntu 16.04 for Production (/post/5a593bfc80aca7059c142975/setup-nodejs-
nginx-and-mongodb-on-ubuntu-1604-for-production)
Node.js and MongoDB Slack Bot Example (/post/5a500c9380aca7059c142973/nodejs-and-mongodb-slack-bot-
example)
Mongo Express Vue Node.js (MEVN Stack) CRUD Web Application (/post/5a1b779f80aca75eadc12d6e/mongo-
express-vue-nodejs-mevn-stack-crud-web-application)
MEAN Stack (Angular 5) CRUD Web Application Example (/post/5a0673c880aca7739224ee21/mean-stack-angular-5-
crud-web-application-example)
Building CRUD Web Application using MERN Stack (/post/59faec0a80aca7739224ee1f/building-crud-web-application-
using-mern-stack)
Node Express Passport Facebook Twitter Google GitHub Login (/post/59a6257180aca768e4d2b132/node-express-
passport-facebook-twitter-google-github-login)
LOG IN WITH
OR SIGN UP WITH DISQUS ?
Name
1 △ ▽ • Reply • Share ›
https://www.djamware.com/post/5d88cb43e7939eec17dc4c89/mean-stack-angular-8-tutorial-build-a-simple-blog-cms 45/48
11/03/2020 MEAN Stack (Angular 8) Tutorial: Build a Simple Blog CMS
1 △ ▽ • Reply • Share ›
./node_modules/mat-contenteditable/fesm2015/mat-contenteditable.js
△ ▽ • Reply • Share ›
△ ▽ • Reply • Share ›
△ ▽ • Reply • Share ›
internal/modules/cjs/loader.js:797
throw err;
Require stack:
- C:\blog-cms\routes\auth.js
- C:\blog-cms\app.js
- C:\blog-cms\bin\www
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:794:15)
at Function.Module._load (internal/modules/cjs/loader.js:687:27)
at Module.require (internal/modules/cjs/loader.js:849:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (C:\blog-cms\routes\auth.js:3:14)
at Module._compile (internal/modules/cjs/loader.js:956:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
at Module.load (internal/modules/cjs/loader.js:812:32)
at Function.Module._load (internal/modules/cjs/loader.js:724:14)
at Module.require (internal/modules/cjs/loader.js:849:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (C:\blog-cms\app.js:6:12)
at Module._compile (internal/modules/cjs/loader.js:956:30)
at Function.Module._load (internal/modules/cjs/loader.js:724:1js:973:10)14) {
code: 'MODULE_NOT_FOUND', 4) {
requireStack: [
'C:\\blog-cms\\routes\\auth.js',
'C:\\blog-cms\\app.js',
'C:\\blog-cms\\bin\\www'
https://www.djamware.com/post/5d88cb43e7939eec17dc4c89/mean-stack-angular-8-tutorial-build-a-simple-blog-cms 46/48
11/03/2020 MEAN Stack (Angular 8) Tutorial: Build a Simple Blog CMS
}
** Angular Live Development Server is listening on localhost:4200, open your browser on http:/, open your browser on
http://localhost:4200/ **
△ ▽ • Reply • Share ›
1 △ ▽ • Reply • Share ›
Programming Blog
(/post-category/595f867edbd39e7571e183dc/programming-blog)
Ionic Framework
(/post-sub-category/5845691a80aca7763489d872/ionic-framework)
MongoDB
(/post-sub-category/5845677b80aca7763489d871/mongodb)
React Native
(/post-sub-category/5b4aa0b480aca707dd4f65a6/react-native)
Groovy and Grails
(/post-sub-category/585b3fa380aca73b19a2efd4/groovy-and-grails)
ASP.NET Core
(/post-sub-category/5c50643780aca754f7a9d1e9/aspnet-core)
HTML 5 Tutorial
(/post-sub-category/584209dffcbe618f680bdc5c/html-5-tutorial)
Java
(/post-sub-category/583d6c37fcbe614473a4c4e8/java)
CSS 3
(/post-sub-category/584249bde4d5d303658d1ecf/css-3)
Javascript
(/post-sub-category/583d6d30fcbe614473a4c4e9/javascript)
Flutter Tutorial
(/post-sub-category/5e1dce2a11c01b0ae0c1c7d9/flutter-tutorial)
Node.js
(/post-sub-category/58a9196f80aca748640ce352/nodejs)
Angular
(/post-sub-category/5d5cb64ffdef3404227777c3/angular)
React.js
(/post-sub-category/5d5cf43bfdef3404227777c5/reactjs)
Vue.js
(/post-sub-category/5d5cf310fdef3404227777c4/vuejs)
All Articles
(/public/allArticles)
Popular Articles:
Angular 8 Tutorial: REST API and HttpClient Examples (51131)
(/post/5d8d7fc10daa6c77eed3b2f2/angular-8-tutorial-rest-api-and-httpclient-examples)
Angular 8 Tutorial: Routing & Navigation Example (28090)
(/post/5d58b409bcc156d4a8a3df8f/angular-8-tutorial-routing-navigation-example)
https://www.djamware.com/post/5d88cb43e7939eec17dc4c89/mean-stack-angular-8-tutorial-build-a-simple-blog-cms 47/48
11/03/2020 MEAN Stack (Angular 8) Tutorial: Build a Simple Blog CMS
Angular 8 Tutorial: Observable and RXJS Examples (21643)
(/post/5da31946ae418d042e1aef1d/angular-8-tutorial-observable-and-rxjs-examples)
Angular 6 HttpClient: Consume RESTful API Example (15478)
(/post/5b87894280aca74669894414/angular-6-httpclient-consume-restful-api-example)
Angular 7 Tutorial: Building CRUD Web Application (13927)
(/post/5bca67d780aca7466989441f/angular-7-tutorial-building-crud-web-application)
Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly (9716)
(/post/5e435e84a8d0ef4300ffc5f6/angular-9-tutorial-learn-to-build-a-crud-angular-app-quickly)
Angular 8 Tutorial: Learn to Build Angular 8 CRUD Web App (9149)
(/post/5d0eda6f80aca754f7a9d1f5/angular-8-tutorial-learn-to-build-angular-8-crud-web-app)
Angular 8 Tutorial: How to Create an Angular Web App Quickly (8197)
(/post/5dde48a430ca212bd263b1b6/angular-8-tutorial-how-to-create-an-angular-web-app-quickly)
Angular Material Form Controls Select (mat-select) Example (7466)
(/post/5e379e4fd598ef0e8bbcc67e/angular-material-form-controls-select-mat-select-example)
Angular Material Form Controls, Form Field and Input Examples (6869)
(/post/5db6c743e3ba1827589f6856/angular-material-form-controls-form-field-and-input-examples)
React Native Tutorial: SQLite Offline Android/iOS Mobile App (6573)
(/post/5caec76380aca754f7a9d1f1/react-native-tutorial-sqlite-offline-androidios-mobile-app)
Push Notification using Ionic 4 and Firebase Cloud Messaging (6505)
(/post/5c6ccd1f80aca754f7a9d1ec/push-notification-using-ionic-4-and-firebase-cloud-messaging)
Ionic 4 Angular 8 Tutorial: Learn to Build CRUD Mobile Apps (5702)
(/post/5d12b5b880aca754f7a9d1f6/ionic-4-angular-8-tutorial-learn-to-build-crud-mobile-apps)
React Native Firebase Cloud Messaging (FCM) Push Notification (5530)
(/post/5d7773f05d8cdc057b603e65/react-native-firebase-cloud-messaging-fcm-push-notification)
Ionic 4, Angular 7 and Cordova Tutorial: Build CRUD Mobile Apps (5398)
(/post/5be52ce280aca72b942e31bc/ionic-4-angular-7-and-cordova-tutorial-build-crud-mobile-apps)
©2012-2018 Djamware.com (http://Djamware.com) | Privacy Policy (/public/privacy) | About Us (/public/about) | Contact Us (/public/contact) | RSS
(https://www.djamware.com/feeds)
https://www.djamware.com/post/5d88cb43e7939eec17dc4c89/mean-stack-angular-8-tutorial-build-a-simple-blog-cms 48/48