CS5220 Advanced Topics in Web Programming Angular – Services

Slides:



Advertisements
Similar presentations
Samsung Smart TV is a web-based application running on an application engine installed on digital TVs connected to the Internet.
Advertisements

Active X Microsoft’s Answer to Dynamic Content Reference: Using Active X by Brian Farrar QUE
Web Integration to an Appx Backend Server. Unix web servers + CGI Win2K web servers + ASP Win2K web servers + ODBC Processing requests Generating HTML.
ITM352 Javascript and Dynamic Web Pages: Client Side Processing.
Christopher Paolini Computational Science Research Center College of Engineering San Diego State University Computational Science 670 Fall 2009 Monday.
1 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
1 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
Overview of Previous Lesson(s) Over View  ASP.NET Pages  Modular in nature and divided into the core sections  Page directives  Code Section  Page.
AJAX Without the “J” George Lawniczak. What is Ajax?
Tutorial 1: Getting Started with Adobe Dreamweaver CS4.
06/10/2015AJAX 1. 2 Introduction All material from AJAX – what is it? Traditional web pages and operation Examples of AJAX use Creating.
CSC 2720 Building Web Applications Server-side Scripting with PHP.
CS320 Web and Internet Programming Web Application and MVC Chengyu Sun California State University, Los Angeles.
CS520 Web Programming Spring – Web MVC Chengyu Sun California State University, Los Angeles.
Struts 2 Development. Topics  Roles in Struts Development  Control Flow  Actions  Struts 2 Views and Target  Struts 2 Custom Tags  Validation 
1 Introduction to Service Component Architecture Feature Pack for WebSphere Application Server & SCA Tooling in RAD Mike Edwards and Sara Mitchell - IBM.
CS520 Web Programming Spring – Inversion of Control Chengyu Sun California State University, Los Angeles.
6. Application Server Issues for the Project
ArcGIS for Server Security: Advanced
Open-O Client Project Proposal
Open-O Client Project Proposal
WWU Hackathon May 6 & 7.
CS5220 Advanced Topics in Web Programming Introduction to WebSocket
Web Development Web Servers.
z/Ware 2.0 Technical Overview
Data Virtualization Tutorial… CORS and CIS
Windows Live Martin Parry Developer and Platform Group Microsoft
Haritha Dasari Josue Balandrano Coronel -
Open-O Client Project Proposal
KnockoutJS -Pradeep Shet 31st August 2014.
Build Better Apps with MEAN.
CS5220 Advanced Topics in Web Programming Course Overview
Angularjs Interview Questions and Answers By Hope Tutors.
SPA Revolution with WebAssembly and Blazor Rainer Stropek | software
Displaying Form Validation Info
SPA Revolution with WebAssembly and Blazor Rainer Stropek | software
CS5220 Advanced Topics in Web Programming Spring – Web MVC
CS320 Web and Internet Programming Cookies and Session Tracking
Lecture 1: Multi-tier Architecture Overview
CS5220 Advanced Topics in Web Programming Angular – Routing
CS320 Web and Internet Programming MVC Architecture
CS5220 Advanced Topics in Web Programming JavaScript Basics
CS5220 Advanced Topics in Web Programming Spring – Web MVC
HTTP GET vs POST SE-2840 Dr. Mark L. Hornick.
CS3220 Web and Internet Programming Introduction to Java Servlets
Chengyu Sun California State University, Los Angeles
Chengyu Sun California State University, Los Angeles
CS5220 Advanced Topics in Web Programming Angular – TypeScript
CS5220 Advanced Topics in Web Programming Angular – Routing
Chengyu Sun California State University, Los Angeles
RESTful Web Services.
Chengyu Sun California State University, Los Angeles
CS5220 Advanced Topics in Web Programming Angular – Services
Chengyu Sun California State University, Los Angeles
Web API with Angular 2 Front End
Angular 2 Michael C. Kang.
CS3220 Web and Internet Programming Cookies and Session Tracking
CS4961 Software Design Laboratory Understand Aquila Backend
Chengyu Sun California State University, Los Angeles
Chengyu Sun California State University, Los Angeles
CS5220 Advanced Topics in Web Programming Angular – TypeScript
CS5220 Advanced Topics in Web Programming Course Overview
Client-Server Model: Requesting a Web Page
Chengyu Sun California State University, Los Angeles
Chengyu Sun California State University, Los Angeles
Introduce to Angular 6 Present by: Võ Văn Hào
Chengyu Sun California State University, Los Angeles
Chengyu Sun California State University, Los Angeles
Chengyu Sun California State University, Los Angeles
CS4540 Special Topics in Web Development Course Overview
Presentation transcript:

CS5220 Advanced Topics in Web Programming Angular – Services Chengyu Sun California State University, Los Angeles

Angular Services Implement business logic of an application Made available to other parts of the application via dependency injection Decorated with @Injectable Declared in providers of @NgModule Injected into constructors

Example: GuestBook App Component GuestBook Component Data Service REST API <router-outlet> AddEntry Component

Changes to AddEntry Form … Name: <input type="text" #name> Message: <input type="text" #message> <button (click)="addEntry(name,message)"> Add </button>

… Changes to AddEntry Form Name: <input type="text" name="name" [(ngModel)]="entry.name"> Message: <input type="text" name="message" [(ngModel)]="entry.message"> <button (click)="addEntry()">Add</button> [(ngModel)] creates a 2-way binding between a form field and a property in the component class "Banana in a box"

Create A Remote Data Service Use Angular CLI to generate a service Naming conventions Add it to AppModule Inject it to component classes

Use HttpClient to Access REST API Import HttpClientModule from @angular/common/http Inject HttpClient to code that needs to make API calls Use HttpClient API, e.g. get

Set Up Proxy During Development … NG Server at Port 4200 Angular App Browser REST API Call API Server at Port 3000 (or 8080) For security reasons, browsers enforce same-origin policy on XMLHttpRequest Localhost

… Set Up Proxy During Development … NG Server at Port 4200 Angular App REST API Call Browser API Server at Port 3000 (or 8080) Localhost

… Set Up Proxy During Development Create proxy configuration file proxy.conf.json, e.g. { "/api": { "target": "http://localhost:3000", "secure": false } Change start script in package.json ng serve --proxy-config proxy.conf.json

Create A Mock Data Service Both remote and mock data service implement the same DataService interface Mock data service stores data locally, but still needs to return Observables

A Simplified View of Some RxJS Concepts Observer Observer Observable Subject … … Observer A Subject is a special type of Observable that allows values to be multicasted to many Observers.

Some Subject Methods next(value) emits the next value error(err) emits an error complete() indicates that the data stream has ended and all subscribers are unsubscribed

BehaviorSubject What if some subscriber comes in late (i.e. after some values are already emitted)? BehaviorSubject is a type of Subject that keeps the latest value vs ReplaySubject

Deploy Angular App Build Angular App: ng build --prod The /dist folder will contain the files to be deployed Because Angular is just JavaScript, HTML, and CSS, an Angular app can be served as static resources as part of a web application or service

More on Express Backend Use express.static() middleware to serve static files Handle nonexistent endpoints/pages Return 404 for REST API calls Return the angular app (i.e. index.html) for nonexistent pages

Port Mappings on VM VM VM … Client VM VM VM … Physical Server 4080 80 3000 VM Client 4088 8080 … VM 4180 80 3000 VM VM 4188 8080 … Physical Server

Readings RxJS Overview