Skip to content

Commit

Permalink
note about ng1 observables
Browse files Browse the repository at this point in the history
  • Loading branch information
mlynch committed Aug 1, 2016
1 parent 06c749f commit 53b6d81
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Ionic Native wraps plugin callbacks in a Promise or [Observable](https://gist.gi
```
import { Geolocation } from 'ionic-native';
Geolocation.getCurrentPosition().then(pos => {
Geolocation.getCurrentPosition().then(pos => {
console.log('lat: ' + pos.coords.latitude + ', lon: ' + pos.coords.longitude);
});
Expand Down Expand Up @@ -49,6 +49,23 @@ angular.module('myApp', ['ionic', 'ionic.native'])
});
```

For services that return observables, the Angular 1 digest cycle must be done manually (currently):

```javascript
angular.module('myApp', ['ionic', 'ionic.native'])

.controller('MyCtrl', function($scope, $cordovaGeolocation) {
$scope.takePicture = function() {
$cordovaGeolocation.watchPosition(opts).subscribe(function(p) {
$scope.$apply(function() {
$scope.position = p.coords;
});
}, function(err) {
});
};
});
```

### Runtime Diagnostics

Spent way too long diagnosing an issue only to realize a plugin wasn't firing or installed? Ionic Native lets you know what the issue is and how you can resolve it.
Expand All @@ -57,7 +74,7 @@ Spent way too long diagnosing an issue only to realize a plugin wasn't firing or

## Installation

Run following commmand to install ionic-native in your project.
Run following commmand to install ionic-native in your project.
```
npm install ionic-native --save
```
Expand Down

0 comments on commit 53b6d81

Please sign in to comment.