Build Better Apps with MEAN.

Slides:



Advertisements
Similar presentations
© 2014 IBM Corporation Empowering the IBM ecosystem Introduction to Developing applications using node.js on Bluemix IBM Ecosystem Development Instructors.
Advertisements

Edoclite and Managing Client Engagements What is Edoclite? How is it used at IU? Development Process?
Overview of Framework by Ahamed Rifaudeen A. page - i Steps before entering into the Framework?  Basic knowledge of object-oriented programming (OOP)
RESTful Web Development With Nodejs and Express. REST Stands for REpresentational State Transfer Has the following constraints: ◦Client-Server ◦Stateless.
NextGen Technology upgrade – Synerizip - Sandeep Kamble.
Real-time Web Application with Node.js CENTRE FOR NETWORK RESEARCH COMPUTER ENGINEERING, PRINCE OF SONGKLA UNIVERSITY 1 Aj. Suthon, Nong Gun, Nong Pop.
LiveCycle Data Services Introduction Part 2. Part 2? This is the second in our series on LiveCycle Data Services. If you missed our first presentation,
An Introduction to Front-end Web Development Tom Perkins.
Node.JS introduction. What is Node.JS? v8 JavaScript runtime Event driven Non-blocking standard libraries Most APIs speak streams Provides a package manager.
MVC Controllers TestsMigrations Ye Olde Internet Model DB Server Router View Browser Today’s focus Controller.
Core ELN Training: Office Web Apps (OWA)
Introduction to MEAN (JavaScript Full Stack Development)
NodeJS and MEAN cs6320.
Web Technologies Computing Science Thompson Rivers University
NodeJS.
MeshCentral 2.0.
Introduction to .NET Florin Olariu
Visual Studio 2017 By Michael Washington
Section 6.3 Server-side Scripting
Angular 4 + TypeScript Getting Started
WWU Hackathon May 6 & 7.
Node.js Express Web Applications
Play Framework: Introduction
NodeJS and MEAN Prof. L. Grewe.
Sarang Nazari California State University, Los Angeles
CMPE 280 Web UI Design and Development October 19 Class Meeting
SharePoint Bruger Gruppe (SPBG) SharePoint Framework Introduction
3 Things Everyone Knows About Node JS That You Don't
CMPE 280 Web UI Design and Development October 24 Class Meeting
In SharePoint A Practical Guide.
JavaScript Basics Stephen Delaney
JavaScript: ExpressJS Overview
Network Programming Lecture 4: Message Posting
SharePoint Cloud hosted Apps
Introduction to SharePoint Framework (SPFx)
A lot of Software Development is about learning
Week 04 (Final Project) Node.js Week 04 (Final Project)
Angularjs Interview Questions and Answers By Hope Tutors.
…and web frameworks in general
Introduction to Docker
MVC Framework, in general.
Microsoft Ignite NZ October 2016 SKYCITY, Auckland.
NodeJS coding basics L. Grewe.
MEAN stack L. Grewe.
Web Browser server client 3-Tier Architecture Apache web server PHP
Introduction to SharePoint Framework (SPFx)
CMPE 280 Web UI Design and Development January 30 Class Meeting
Nathan Totten Technical Evangelist Windows Azure
Module P3 Practical: Building a webapp in nodejs and
CMPE 280 Web UI Design and Development January 29 Class Meeting
Web Programming Language
What’s new in ASP.NET Core and Entity Framework 2.2 (Preview 3)
TechEd /22/2019 9:22 PM © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks.
Web Service Installation and Configuration
…and web frameworks in general
RESTful Web Services.
CS5220 Advanced Topics in Web Programming Angular – Services
Augmented Reality: Internet of Things
Web API with Angular 2 Front End
Lecture 12: The Fetch Api and AJAx
Lecture 19: post and Public APIS
Poster Child for Continuous Improvement
Web Technologies Computing Science Thompson Rivers University
Week 05 Node.js Week 05
Introduction.
Augmented Reality: Internet of Things
Introduce to Angular 6 Present by: Võ Văn Hào
CS5220 Advanced Topics in Web Programming Angular – Services
Angular.
CMPE 280 Web UI Design and Development August 27 Class Meeting
Presentation transcript:

Build Better Apps with MEAN

MEAN Scaffolding Sample- App Agenda

So why MEAN?

Why MEAN? MongoDB usually acts as the database for your application, in case you need to persist data. It's where we store records. ExpressJS is a web framework for nodejs, usually used as a backend for web apps in the MEAN stack. Angular is usually the client side MVC web framework. In this case, we will be using Angular 2.*. NodeJS powers express, and will be the layer our server run on. Angular and web development == awesome

Scaffolding

Angular CLI The Angular CLI makes it easy to create an application that already works, right out of the box. It already follows our best practices! A command line interface for Angular.

Bootstrapping the App $ npm install -g angular-cli $ ng new mean-app This will scaffold an Angular 2 app and install all the dependencies.  To run $ ng serve and hit http://localhost:4200

Express

Install Dependencies $ npm install --save express body-parser Now create a file server.js and a folder server in the root of our angular project. The server.js file will have the server code, that will point to the server folder.

Server.js This code sets up a simple express app, with an /api route and all other routes are directed towards the dist/index.html page. To catch all route, denoted with *, MUST come last after all other API routes have been defined. The /api route points to a file ./server/routes/api.js.

Server.js

api.js

Build Since the route is pointing to dist/index.html, we need to do a build of the angular app. $ ng build $ node server.js Now hit http://localhost:3000 or http://localhost:3000/api

Server Data Let's mock up some data for three route endpoints. We'll call the mock api to respond with some data. Update the api.js For making http requests. $ npm install --save axios

Update Api.js Now hit http://localhost:3000/api/posts

Angular Route, Component We'll add an angular component, then add a route that display this component's template. $ ng generate component posts This adds a new folder in the src/app directory, called posts. Also imports the generated PostComponent in the src/app/app.module.ts file, and adds it to the declarations property of the @NgModuledecorator.

Add Routes We are simply telling our router that whenever the root route / is visited, redirect to /posts. We then declare the /posts route. Add a router-outlet where the route should be rendered. We'll add this in the src/app/app.component.html. $ ng build && node server.js Going to http://localhost:3000 should redirect you to http://locahost:3000/posts, based on the instructions we gave to our router.

Add Route

Router Outlet

Connect Route to Express $ ng generate service posts Recommends defining a provider or service to handle the http calls. Creates a posts.service.ts in the src/app directory. We then need to add it in the providers section of our module declaration. Make the call to Express server Import the service in post component src/app/posts/posts.component.ts

Make the http call

Add to module

Import the service in post component

View Finally, we'll just display the posts in the view. src/app/posts/posts.component.html

Step-By-Step npm install -g angular-cli ng new mean-app ng serve Hit http://localhost:4200 npm install --save express body-parser Add server.js & server/routes/api.js (Refer code zip) ng build node server.js Hit http://localhost:3000 npm install --save axios Update server/routes/api.js (Refer code zip) ng generate component posts

Step-By-Step Declare the /posts route in src/app/app.module.ts (Refer code zip) Add a router-outlet where the route should be rendered in the src/app/app.component.html (Refer code zip) ng build && node server.js ng generate service posts Update src/app/posts.service.ts and src/app/app.module.ts (Refer code zip) Import service in src/app/posts/posts.component.ts (Refer code zip) Update src/app/posts/posts.component.html and add bootstrap CDN to src/index.html(Refer code zip) ng build && node server.js (hit http://localhost:3000)

https://scotch.io/tutorials/mean-app-with-angular-2-and-the-angular-cli

Thanks!