SlideShare a Scribd company logo
Angular 4 for Java
Developers
Yakov Fain
Farata Systems

yfain
By the end of this presentation you
won’t become an Angular expert,
but you’ll start being dangerous!
The Legal Slide
About myself
• Work for Farata Systems 

Angular practice lead
• Java Champion
• Latest book:

“Angular Development with TypeScript”
ctwdevoxxus

40% off
Agenda
• High-level overview of the Angular framework and TypeScript
• Generating and bundling a project with Angular CLI
• Start a Java REST service with Spring Boot
• Create an Angular REST client and deploy it under Spring
Boot
• Demo of a sample Angular app that uses REST and
WebSockets
Angular Framework
• Component-based (not MVC)
• Dependency Injection
• Router
• Integrated RxJS
• Can write apps in TypeScript, Dart, or JavaScript
• UI components: Angular Material 2
• The rendering engine
The landing page of an Auction app
An app is a tree of components
HTML
import {Component} from '@angular/core';

import {Product, ProductService} from '../services/product-service';



@Component({

selector: 'app-root', 

templateUrl: 'application.html',

styleUrls: ['application.css']

})

export class AppComponent {

products: Array<Product> = []; 



constructor(private productService: ProductService) { 

this.products = this.productService.getProducts(); 

}

}
HTML, CSS
TypeScript
TypeScript

for Java Developers
Arrow Function Expressions
let getName = () => 'John Smith';
console.log(`The name is ` + getName());
Anonymous

function
A Class With Constructor
TypeScript JavaScript (ES5)
Inheritance
Classical Prototypal
Generics
Compile time error
No Errors
Interfaces
No interfaces
in JavaScript
Angular CLI
What’s Angular CLI
• Scaffolding the project and creating a basic app
• Generating components, services, modules, etc.
• Serving the app to the browser
• Bundling apps for dev and prod deployments
• Generates boilerplate unit tests and configures test
runners
Demo
- Generating a new project

- Dev and prod builds with Angular CLI
Single Page Apps
Router’s features
- Pass data to routes
- Child component can have their routes
- Multiple router outlets
- Guarding routes
- Lazy loading of modules
Dependency Injection
• Angular injects values into components via constructors
• Each component has its own injector
• You specify a provider so Angular knows what to inject
A sample injectable service
@Injectable()
export class ProductService{


getProducts(): Product {

// An HTTP request can go here 



return new Product( 0, "iPhone 7", 249.99, "The latest iPhone, 7-inch screen");

}

}
Injecting the ProductService
import {Component} from ‘@angular/core';

import {ProductService, Product} from “./product.service";



@Component({

selector: 'di-product-page',

template: `<div>

<h1>Product Details</h1>

<h2>Title: {{product.title}}</h2>

<h2>Description: {{product.description}}</h2>

<h2>Price: ${{product.price}}</h2>

</div>`,

providers:[ProductService]

})



export class ProductComponent {

product: Product;



constructor( productService: ProductService ) {

this.product = productService.getProduct();

}

}
Injection
Reactive Programming: Push
Subscribe to messages from Observable and handle them by Observer
Observer
Subscriber
Observer
Subscriber
push
push
push
Observer
Subscriber
Observable
Data

Source
Reactive programming in Angular
- Router

- Reactive Forms

- EventEmitter (a subclass of Subject)
- Handling HTTP responses

- WebSockets
Http and Observables


class AppComponent implements OnInit{



products: Array = [];



constructor(private http: Http) {}
ngOnInit() {

this.http.get(‘/api/products’)

.map(res => res.json()) // Turn JSON from HTTP response into JS obj

.subscribe(

data => {



this.products=data;

},



err =>

console.log("Can't get products. Error code: %s, URL: %s ",

err.status, err.url),



() => console.log('Product(s) are retrieved')

);

}

}
O
b
s
e
r
v
e
r
Inter-component
communications
@Input properties
@Component({

selector: 'order-processor',

template: `...`

})
class OrderComponent {



@Input() quantity: number;



@Input()

set stockSymbol(value: string) {

// process the stockSymbol change here

}

<order-processor [stockSymbol]="stock" quantity="100"></order-processor>
Child
Parent
@Output properties
class PriceQuoterComponent {



@Output() lastPrice: EventEmitter <IPriceQuote> = new EventEmitter();



stockSymbol: string = "IBM";



constructor() {

setInterval(() => {

let priceQuote: IPriceQuote = {

stockSymbol: this.stockSymbol,

lastPrice: 100*Math.random()

};



this.lastPrice.emit(priceQuote);



}, 1000);

}

}
<price-quoter (lastPrice)="priceQuoteHandler($event)"></price-quoter><br>
Child
Parent
An injectable service as a mediator
Forms API
- Template-driven forms
- Reactive forms
- Form validation
A template-driven form
@Component({

selector: 'app-root',

template: `

<form #f="ngForm" (ngSubmit)="onSubmit(f.value)">

<div>Username: <input type="text" name="username" ngModel></div>

<div>SSN: <input type="text" name="ssn" ngModel></div>

<div>Password: <input type="password" name="password" ngModel></div>

<div>Confirm password: <input type="password" name="pconfirm" ngModel></div>

<button type="submit">Submit</button>

</form>

`

})

export class AppComponent {

onSubmit(formData) {

console.log(formData);

}

}
"scripts": {



"start": "ng serve --proxy-config proxy.conf.json",



"build": "ng build -prod",



"postbuild": "npm run deploy”,


"predeploy": "rimraf ../server/build/public
&& mkdirp ../server/build/public”,


"deploy": "copyfiles -f dist/** ../server/build/public"

}
Automating deployments with
npm scripts
static

resources
Demo

Angular + Spring Boot
Java
Angular
Designed in 1995 in Norway (still alive)
What’s Material Design?
Material design is visual language (a spec) that defines
the classic principles of good design.
Palettes
Angular Material 2
Need more components? Use the library PrimeNG
Demo
Thank you!
• The book code samples:

https://github.com/Farata/angular2typescript
• Training inquiries: 

training@faratasystems.com
• My blog:

yakovfain.com
• Twitter: @yfain

ctwdevoxxus

40% off

More Related Content

PDF
Angular2 Development for Java developers
PDF
RESTful services and OAUTH protocol in IoT
PPTX
PPTX
Angular 4 Introduction Tutorial
PDF
Integrating consumers IoT devices into Business Workflow
PPTX
Angular 4
PPTX
Angular js 2
PDF
Understanding Angular 2 - Shmuela Jacobs - Codemotion Milan 2016
Angular2 Development for Java developers
RESTful services and OAUTH protocol in IoT
Angular 4 Introduction Tutorial
Integrating consumers IoT devices into Business Workflow
Angular 4
Angular js 2
Understanding Angular 2 - Shmuela Jacobs - Codemotion Milan 2016

What's hot (20)

PDF
Exploring Angular 2 - Episode 2
PPTX
Introduction to Angular JS
PDF
Web sockets in Angular
PDF
Angular 2 Essential Training
PPTX
Async patterns in javascript
PPTX
AngularJs presentation
PDF
Overview of the AngularJS framework
PPTX
Introduction to angular with a simple but complete project
PPTX
AngularJS2 / TypeScript / CLI
PDF
Data Flow Patterns in Angular 2 - Sebastian Müller
PDF
Reactive Thinking in Java with RxJava2
PDF
Exploring Angular 2 - Episode 1
PPTX
Angular JS, steal the idea
PPTX
An afternoon with angular 2
PDF
Tech Webinar: Angular 2, Introduction to a new framework
PDF
Angular 2 - The Next Framework
PDF
Angular 2: core concepts
PDF
Introduction to Angular 2
PDF
Angular server side rendering - Strategies & Technics
Exploring Angular 2 - Episode 2
Introduction to Angular JS
Web sockets in Angular
Angular 2 Essential Training
Async patterns in javascript
AngularJs presentation
Overview of the AngularJS framework
Introduction to angular with a simple but complete project
AngularJS2 / TypeScript / CLI
Data Flow Patterns in Angular 2 - Sebastian Müller
Reactive Thinking in Java with RxJava2
Exploring Angular 2 - Episode 1
Angular JS, steal the idea
An afternoon with angular 2
Tech Webinar: Angular 2, Introduction to a new framework
Angular 2 - The Next Framework
Angular 2: core concepts
Introduction to Angular 2
Angular server side rendering - Strategies & Technics
Ad

Viewers also liked (8)

PDF
Developing a Demo Application with Angular 4 - J2I
PPTX
WebSphere App Server vs JBoss vs WebLogic vs Tomcat (InterConnect 2016)
PDF
Angular 2 for Java Developers
PPTX
PDF
Introduction To Angular 4 - J2I
PDF
Alphorm.com Formation Angular - Les fondamentaux
ODP
Introduction to Angular 2
PPTX
AI and Machine Learning Demystified by Carol Smith at Midwest UX 2017
Developing a Demo Application with Angular 4 - J2I
WebSphere App Server vs JBoss vs WebLogic vs Tomcat (InterConnect 2016)
Angular 2 for Java Developers
Introduction To Angular 4 - J2I
Alphorm.com Formation Angular - Les fondamentaux
Introduction to Angular 2
AI and Machine Learning Demystified by Carol Smith at Midwest UX 2017
Ad

Similar to Angular 4 for Java Developers (20)

PDF
Angular 2 overview in 60 minutes
PPTX
Building a TV show with Angular, Bootstrap, and Web Services
PDF
Angular training-course-syllabus
PDF
better-apps-angular-2-day1.pdf and home
PPT
17612235.ppt
PPTX
Angularj2.0
PPTX
Presentation on angular 5
PDF
Angular2
PPTX
Angular crash course
PDF
Angular training-course-syllabus
PDF
Angular 7 training_topics
PDF
Angular2 with type script
PDF
Mastering angular - Dot Net Tricks
PPTX
Angularjs2 presentation
PDF
Angular JS2 Training Session #2
PDF
Building Powerful Applications with AngularJS 2 and TypeScript - David Giard
PDF
Angular js
PDF
Angular js
PPTX
yrs of IT experience in enterprise programming
Angular 2 overview in 60 minutes
Building a TV show with Angular, Bootstrap, and Web Services
Angular training-course-syllabus
better-apps-angular-2-day1.pdf and home
17612235.ppt
Angularj2.0
Presentation on angular 5
Angular2
Angular crash course
Angular training-course-syllabus
Angular 7 training_topics
Angular2 with type script
Mastering angular - Dot Net Tricks
Angularjs2 presentation
Angular JS2 Training Session #2
Building Powerful Applications with AngularJS 2 and TypeScript - David Giard
Angular js
Angular js
yrs of IT experience in enterprise programming

More from Yakov Fain (17)

PDF
Type script for_java_dev_jul_2020
PDF
Using JHipster for generating Angular/Spring Boot apps
PDF
Using JHipster for generating Angular/Spring Boot apps
PDF
TypeScript for Java Developers
PDF
Reactive Streams and RxJava2
PDF
Using JHipster 4 for generating Angular/Spring Boot apps
PDF
Reactive programming in Angular 2
PDF
Reactive Thinking in Java
PDF
Dart for Java Developers
PDF
Intro to JavaScript
PDF
Seven Versions of One Web Application
PDF
Java Intro: Unit1. Hello World
PDF
Running a Virtual Company
PDF
Princeton jug git_github
PDF
Speed up your Web applications with HTML5 WebSockets
PDF
Surviving as a Professional Software Developer
PDF
Becoming a professional software developer
Type script for_java_dev_jul_2020
Using JHipster for generating Angular/Spring Boot apps
Using JHipster for generating Angular/Spring Boot apps
TypeScript for Java Developers
Reactive Streams and RxJava2
Using JHipster 4 for generating Angular/Spring Boot apps
Reactive programming in Angular 2
Reactive Thinking in Java
Dart for Java Developers
Intro to JavaScript
Seven Versions of One Web Application
Java Intro: Unit1. Hello World
Running a Virtual Company
Princeton jug git_github
Speed up your Web applications with HTML5 WebSockets
Surviving as a Professional Software Developer
Becoming a professional software developer

Recently uploaded (20)

PDF
KodekX | Application Modernization Development
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPTX
Big Data Technologies - Introduction.pptx
PDF
Empathic Computing: Creating Shared Understanding
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
Telecom Fraud Prevention Guide | Hyperlink InfoSystem
PDF
Electronic commerce courselecture one. Pdf
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
GDG Cloud Iasi [PUBLIC] Florian Blaga - Unveiling the Evolution of Cybersecur...
PPTX
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
PPTX
Cloud computing and distributed systems.
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Modernizing your data center with Dell and AMD
KodekX | Application Modernization Development
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
The Rise and Fall of 3GPP – Time for a Sabbatical?
Reach Out and Touch Someone: Haptics and Empathic Computing
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Big Data Technologies - Introduction.pptx
Empathic Computing: Creating Shared Understanding
NewMind AI Weekly Chronicles - August'25 Week I
Telecom Fraud Prevention Guide | Hyperlink InfoSystem
Electronic commerce courselecture one. Pdf
NewMind AI Monthly Chronicles - July 2025
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
CIFDAQ's Market Insight: SEC Turns Pro Crypto
GDG Cloud Iasi [PUBLIC] Florian Blaga - Unveiling the Evolution of Cybersecur...
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
Cloud computing and distributed systems.
Chapter 3 Spatial Domain Image Processing.pdf
Modernizing your data center with Dell and AMD

Angular 4 for Java Developers

  • 1. Angular 4 for Java Developers Yakov Fain Farata Systems
 yfain
  • 2. By the end of this presentation you won’t become an Angular expert, but you’ll start being dangerous! The Legal Slide
  • 3. About myself • Work for Farata Systems 
 Angular practice lead • Java Champion • Latest book:
 “Angular Development with TypeScript” ctwdevoxxus
 40% off
  • 4. Agenda • High-level overview of the Angular framework and TypeScript • Generating and bundling a project with Angular CLI • Start a Java REST service with Spring Boot • Create an Angular REST client and deploy it under Spring Boot • Demo of a sample Angular app that uses REST and WebSockets
  • 5. Angular Framework • Component-based (not MVC) • Dependency Injection • Router • Integrated RxJS • Can write apps in TypeScript, Dart, or JavaScript • UI components: Angular Material 2 • The rendering engine
  • 6. The landing page of an Auction app
  • 7. An app is a tree of components
  • 9. import {Component} from '@angular/core';
 import {Product, ProductService} from '../services/product-service';
 
 @Component({
 selector: 'app-root', 
 templateUrl: 'application.html',
 styleUrls: ['application.css']
 })
 export class AppComponent {
 products: Array<Product> = []; 
 
 constructor(private productService: ProductService) { 
 this.products = this.productService.getProducts(); 
 }
 } HTML, CSS TypeScript
  • 11. Arrow Function Expressions let getName = () => 'John Smith'; console.log(`The name is ` + getName()); Anonymous
 function
  • 12. A Class With Constructor TypeScript JavaScript (ES5)
  • 17. What’s Angular CLI • Scaffolding the project and creating a basic app • Generating components, services, modules, etc. • Serving the app to the browser • Bundling apps for dev and prod deployments • Generates boilerplate unit tests and configures test runners
  • 18. Demo - Generating a new project
 - Dev and prod builds with Angular CLI
  • 20. Router’s features - Pass data to routes - Child component can have their routes - Multiple router outlets - Guarding routes - Lazy loading of modules
  • 21. Dependency Injection • Angular injects values into components via constructors • Each component has its own injector • You specify a provider so Angular knows what to inject
  • 22. A sample injectable service @Injectable() export class ProductService{ 
 getProducts(): Product {
 // An HTTP request can go here 
 
 return new Product( 0, "iPhone 7", 249.99, "The latest iPhone, 7-inch screen");
 }
 }
  • 23. Injecting the ProductService import {Component} from ‘@angular/core';
 import {ProductService, Product} from “./product.service";
 
 @Component({
 selector: 'di-product-page',
 template: `<div>
 <h1>Product Details</h1>
 <h2>Title: {{product.title}}</h2>
 <h2>Description: {{product.description}}</h2>
 <h2>Price: ${{product.price}}</h2>
 </div>`,
 providers:[ProductService]
 })
 
 export class ProductComponent {
 product: Product;
 
 constructor( productService: ProductService ) {
 this.product = productService.getProduct();
 }
 } Injection
  • 24. Reactive Programming: Push Subscribe to messages from Observable and handle them by Observer Observer Subscriber Observer Subscriber push push push Observer Subscriber Observable Data
 Source
  • 25. Reactive programming in Angular - Router
 - Reactive Forms
 - EventEmitter (a subclass of Subject) - Handling HTTP responses
 - WebSockets
  • 26. Http and Observables 
 class AppComponent implements OnInit{
 
 products: Array = [];
 
 constructor(private http: Http) {} ngOnInit() {
 this.http.get(‘/api/products’)
 .map(res => res.json()) // Turn JSON from HTTP response into JS obj
 .subscribe(
 data => {
 
 this.products=data;
 },
 
 err =>
 console.log("Can't get products. Error code: %s, URL: %s ",
 err.status, err.url),
 
 () => console.log('Product(s) are retrieved')
 );
 }
 } O b s e r v e r
  • 28. @Input properties @Component({
 selector: 'order-processor',
 template: `...`
 }) class OrderComponent {
 
 @Input() quantity: number;
 
 @Input()
 set stockSymbol(value: string) {
 // process the stockSymbol change here
 }
 <order-processor [stockSymbol]="stock" quantity="100"></order-processor> Child Parent
  • 29. @Output properties class PriceQuoterComponent {
 
 @Output() lastPrice: EventEmitter <IPriceQuote> = new EventEmitter();
 
 stockSymbol: string = "IBM";
 
 constructor() {
 setInterval(() => {
 let priceQuote: IPriceQuote = {
 stockSymbol: this.stockSymbol,
 lastPrice: 100*Math.random()
 };
 
 this.lastPrice.emit(priceQuote);
 
 }, 1000);
 }
 } <price-quoter (lastPrice)="priceQuoteHandler($event)"></price-quoter><br> Child Parent
  • 30. An injectable service as a mediator
  • 31. Forms API - Template-driven forms - Reactive forms - Form validation
  • 32. A template-driven form @Component({
 selector: 'app-root',
 template: `
 <form #f="ngForm" (ngSubmit)="onSubmit(f.value)">
 <div>Username: <input type="text" name="username" ngModel></div>
 <div>SSN: <input type="text" name="ssn" ngModel></div>
 <div>Password: <input type="password" name="password" ngModel></div>
 <div>Confirm password: <input type="password" name="pconfirm" ngModel></div>
 <button type="submit">Submit</button>
 </form>
 `
 })
 export class AppComponent {
 onSubmit(formData) {
 console.log(formData);
 }
 }
  • 33. "scripts": {
 
 "start": "ng serve --proxy-config proxy.conf.json",
 
 "build": "ng build -prod",
 
 "postbuild": "npm run deploy”, 
 "predeploy": "rimraf ../server/build/public && mkdirp ../server/build/public”, 
 "deploy": "copyfiles -f dist/** ../server/build/public"
 } Automating deployments with npm scripts static
 resources
  • 34. Demo
 Angular + Spring Boot Java Angular
  • 35. Designed in 1995 in Norway (still alive)
  • 36. What’s Material Design? Material design is visual language (a spec) that defines the classic principles of good design.
  • 38. Angular Material 2 Need more components? Use the library PrimeNG
  • 39. Demo
  • 40. Thank you! • The book code samples:
 https://github.com/Farata/angular2typescript • Training inquiries: 
 [email protected] • My blog:
 yakovfain.com • Twitter: @yfain
 ctwdevoxxus
 40% off