mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-01-19 08:32:52 +08:00
docs(readme): update examples
This commit is contained in:
parent
956e644fa4
commit
28a1b83d1d
26
README.md
26
README.md
@ -47,17 +47,15 @@ export class AppModule { }
|
|||||||
import { Geolocation } from '@ionic-native/geolocation';
|
import { Geolocation } from '@ionic-native/geolocation';
|
||||||
import { Platform } from 'ionic-angular';
|
import { Platform } from 'ionic-angular';
|
||||||
|
|
||||||
import { NgZone } from '@angular/core';
|
|
||||||
|
|
||||||
@Component({ ... })
|
@Component({ ... })
|
||||||
export class MyComponent {
|
export class MyComponent {
|
||||||
|
|
||||||
constructor(private geolocation: Geolocation, private platform: Platform) {
|
constructor(private geolocation: Geolocation, private platform: Platform) {
|
||||||
|
|
||||||
platform.ready().then(() => {
|
this.platform.ready().then(() => {
|
||||||
|
|
||||||
// get position
|
// get position
|
||||||
geolocation.getCurrentPosition().then(pos => {
|
this.geolocation.getCurrentPosition().then(pos => {
|
||||||
console.log(`lat: ${pos.coords.latitude}, lon: ${pos.coords.longitude}`)
|
console.log(`lat: ${pos.coords.latitude}, lon: ${pos.coords.longitude}`)
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -65,7 +63,6 @@ export class MyComponent {
|
|||||||
// watch position
|
// watch position
|
||||||
const watch = geolocation.watchPosition().subscribe(pos => {
|
const watch = geolocation.watchPosition().subscribe(pos => {
|
||||||
console.log(`lat: ${pos.coords.latitude}, lon: ${pos.coords.longitude}`)
|
console.log(`lat: ${pos.coords.latitude}, lon: ${pos.coords.longitude}`)
|
||||||
this.position = pos;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// to stop watching
|
// to stop watching
|
||||||
@ -112,19 +109,19 @@ providers: [
|
|||||||
Here's the full example:
|
Here's the full example:
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
import { NgModule, ErrorHandler } from '@angular/core';
|
import { ErrorHandler, NgModule } from '@angular/core';
|
||||||
import { BrowserModule } from '@angular/platform-browser';
|
import { BrowserModule } from '@angular/platform-browser';
|
||||||
import { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular';
|
|
||||||
import { MyApp } from './app.component';
|
|
||||||
import { HomePage } from '../pages/home/home';
|
|
||||||
|
|
||||||
import { Camera } from '@ionic-native/camera';
|
import { Camera } from '@ionic-native/camera';
|
||||||
|
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
|
||||||
|
|
||||||
|
import { HomePage } from '../pages/home/home';
|
||||||
|
import { MyApp } from './app.component';
|
||||||
|
|
||||||
class CameraMock extends Camera {
|
class CameraMock extends Camera {
|
||||||
getPicture(options) {
|
getPicture(options) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
resolve("BASE_64_ENCODED_DATA_GOES_HERE");
|
resolve('BASE_64_ENCODED_DATA_GOES_HERE');
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,11 +140,12 @@ class CameraMock extends Camera {
|
|||||||
HomePage
|
HomePage
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
{provide: ErrorHandler, useClass: IonicErrorHandler},
|
{ provide: ErrorHandler, useClass: IonicErrorHandler },
|
||||||
{ provide: Camera, useClass: CameraMock }
|
{ provide: Camera, useClass: CameraMock }
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
export class AppModule {}
|
export class AppModule {}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -169,6 +167,8 @@ For Ionic v1 (AngularJS, Angular 1.x) support, please use version 2 of Ionic Nat
|
|||||||
|
|
||||||
Ibby Hadeed - [@ihadeed](https://github.com/ihadeed)
|
Ibby Hadeed - [@ihadeed](https://github.com/ihadeed)
|
||||||
|
|
||||||
|
Daniel Sogl - [@sogldaniel](https://twitter.com/sogldaniel)
|
||||||
|
|
||||||
Tim Lancina - [@timlancina](https://twitter.com/timlancina)
|
Tim Lancina - [@timlancina](https://twitter.com/timlancina)
|
||||||
|
|
||||||
Mike Hartington - [@mhartington](https://twitter.com/mhartington)
|
Mike Hartington - [@mhartington](https://twitter.com/mhartington)
|
||||||
|
Loading…
Reference in New Issue
Block a user