Luis Henrique G Camilo
Software Engineer
2
Distribution
Capabilities
Performance
Productivity
# Install ionic tools
$ npm install -g cordova ionic
# Create Ionic 2 project
$ ionic start example
# Run Ionic 2 project
$ ionic serve
# Build the project
$ ionic build
# Generate pipes, components, pages, directives, providers, and tabs (ionic-angular >= 3.0.0)
$ ionic generate pipes|components|pages|directive|providerhttp://ionicframework.com/getting-started/
{
"name": "Angular Hack Day Ionic 2 PWA",
"short_name": "AngularHackDay",
"description": "Ionic 2 PWA demo for Angular Hack Day - Sydney",
"start_url": "index.html",
"display": "standalone",
"orientation": "portrait",
"background_color": "#79C273",
"theme_color": "#79C273",
"icons": [{
"src": "../resources/android/icon/drawable-ldpi-icon.png",
"sizes": "36x36",
"type": "image/png"
},
...
],
"related_applications": [{
"platform": "web",
"url": "https://.../"
}]
}https://developer.mozilla.org/en-US/Add-ons/WebExtensions/manifest.json
Enable home screen install
https://developers.google.com/web/fundamentals/getting-started/primers/service-workers
Enable offline capability
https://serviceworke.rs/
https://developer.mozilla.org/en-US/docs/Web/HTML/Using_the_application_cache
As a fallback
https://goo.gl/ec1p6N
# install cordova in global scope
$ npm install -g ionic cordovaPrimeiro, tenha certeza que o nodejs6+ esteja instalado na sua máquina
# Create your fist mobile app
$ ionic start cutePuppyPics
$ cd cutePuppyPics
$ ionic serve
# Create your fist mobile app
$ ionic start cutePuppyPics tabs
import { Component } from `@angular/core`;
import { StartPage } from './start-page';
@Component(
template: `<ion-nav [root]="rootPage"></ion-nav>`
})
class MyApp {
// set the rootPage to the first page we want displayed
public rootPage: any = StartPage;
constructor(){
}
}import { NavController } from 'ionic-angular';
class MyComponent {
constructor(public navCtrl: NavController) {
}
}Injetando NavController
import { Component, ViewChild } from '@angular/core';
import { NavController } from 'ionic-angular';
@Component({
template: '<ion-nav #myNav [root]="rootPage"></ion-nav>'
})
export class MyApp {
@ViewChild('myNav')
nav: NavController;
public rootPage: any = TabsPage;
/** Wait for the components in MyApp's template to be initialized
* In this case, we are waiting for the Nav with reference variable of "#myNav"
*/
ngOnInit() {
// Let's navigate from TabsPage to Page1
this.nav.push(Page1);
}
}import { Component } from '@angular/core';
import { App, ViewController } from 'ionic-angular';
@Component({
template: `
<ion-content>
<h1>My PopoverPage</h1>
<button ion-button (click)="pushPage()">Call pushPage</button>
</ion-content>
`
})
class PopoverPage {
constructor(
public viewCtrl: ViewController
public appCtrl: App
) {}
pushPage() {
this.viewCtrl.dismiss();
this.appCtrl.getRootNav().push(SecondPage);
}
}lhenriquegomescamilo
lhenriquegomescamilo