Reputation: 1
I implemented the gyroscope from https://github.com/NeoLSN/cordova-plugin-gyroscope and then, when i imported it as an Angular i got
Cannot find name 'constructor'. And other errors concerning the import below from https://ionicframework.com/docs/native/gyroscope.
Does anyone have a complete version?
import { Gyroscope, GyroscopeOrientation, GyroscopeOptions } from '@ionic-native/gyroscope/ngx';
constructor(private gyroscope: Gyroscope) { }
...
let options: GyroscopeOptions = {
frequency: 1000
}
this.gyroscope.getCurrent(options)
.then((orientation: GyroscopeOrientation) => {
console.log(orientation.x, orientation.y, orientation.z, orientation.timestamp);
})
.catch()
this.gyroscope.watch()
.subscribe((orientation: GyroscopeOrientation) => {
console.log(orientation.x, orientation.y, orientation.z, orientation.timestamp);
});
Upvotes: 0
Views: 126
Reputation: 1
app.module.ts
:import { Gyroscope, GyroscopeOrientation, GyroscopeOptions } from '@ionic-native/gyroscope/ngx';
@NgModule({
...
...
...
providers: [....,Gyroscope],
})
After this steps you should be done.
Upvotes: 0