The 7 Things I Know About Cyber Security After 25 Years | April 2024
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
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
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");
}
}
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
40. 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