Wilson Mendes
@willmendesneto
Google Developer Expert Web Technologies
1. Access https://goo.gl/PibUcQ
2. Decrease the price to $0,00
3. Enjoy
<page-container>
</page-container>
<component1 />
<component2>
</component2>
<component3 />
npm install -g @angular/cli
// Installing Angular CLI
ng new my-app
// Creating a new Angular App
ng serve
// Starting local server
# Adding inline style and inline template
{
...
"defaultProject": "my-app",
"schematics": {
"@schematics/angular": {
"component": {
"inlineStyle": true,
"inlineTemplate": true
}
}
}
...
}
// create a resolver
export class ListingItemResolver implements Resolve<ListingItem> {
constructor(
private service: ListingItemService
) {}
resolve(route: ActivatedRouteSnapshot) {
const id = route.paramMap.get('id');
return this.service
.getListingItem(id);
}
}
// Adding `ListingItemResolver`
// resolver in your route
const routes: Routes = [{
path: ':id',
component: ListingItemDetailContainerComponent,
resolve: { item: ListingItemResolver },
}];
ng g universal
--clientProject my-app
// Configuring Angular universal
ng build my-app --prod
// Build app in prod mode
ng run my-app:server:production
// Run server in prod mode
// Create a service to handle
// all the changes in the main tags
// `metatags`, `title`, etc
export class LayoutService {
constructor(private meta: Meta, private title: Title) { }
public setMetaData(config) {
this.title.setTitle('Page Title');
const tags = [
{ name: 'description', content: 'Description' },
{ name: 'theme-color', content: '#333' },
{ property: 'og:title', content: title },
{ property: 'og:description', content: 'Description' },
{ property: 'og:image', content: '/image.png' },
];
tags.forEach(tag => this.meta.updateTag(tag));
}
}
or
ng add @angular/pwa
// PWA support out of the box
<!-- Add it in your `src/index.html` -->
<noscript>
<p>This page is best viewed using JavaScript.</p>
</noscript>
// Caching external resources
// in your service worker
{
...
{
"name": "externals",
"installMode": "prefetch",
"updateMode": "prefetch",
"resources": {
"urls": [
"https://ajax.googleapis.com/**",
"https://fonts.googleapis.com/**",
"https://fonts.gstatic.com/**",
"<your-cdn-url>"
]
}
}
}
// Storing your API responses
// using Service Workers
{
...
"dataGroups": [{
"name": "rest-api",
"urls": [
"<your-api-url>/**"
],
"cacheConfig": {
"strategy": "freshness",
"maxSize": 100,
"maxAge": "1h", // how long it should be stored?
"timeout": "5s"
}
}]
<!DOCTYPE html>
<html
itemtype="http://schema.org/Product"
lang="en"
>
<head>
...
</head>
<body>
<h1 itemprop="name">Title goes here ...</h1>
<time
datetime="2018-10-08 15:49:40 -0300"
itemprop="datePublished"
>
October 8th, 2018
</time>
...
</body>
</html>
<script type="application/ld+json">
{
"@context": {
"name": "http://xmlns.com/foaf/0.1/name",
"homepage": {
"@id": "http://xmlns.com/foaf/0.1/workplaceHomepage",
"@type": "@id"
},
"Person": "http://xmlns.com/foaf/0.1/Person"
},
"@id": "https://me.example.com",
"@type": "Person",
"name": "John Smith",
"homepage": "https://www.example.com/"
}
</script>
Wilson Mendes
@willmendesneto
Google Developer Expert Web technologies