yoke92
February 13, 2017, 8:39am
1
i just installed the plugin and i am trying to see weather i could get some data so i did like this import { DBMeter } from 'ionic-native'; constructor(public dbMeter: DBMeter) { } startRecording(){ console.log("Db meter"); DBMeter.start().subscribe( data => console.log(data) )};
when i do like this i get this error inline template:44:8 caused by: No provider for DBMeter!
could some one help me.
I have the same issue …
I´ve runned bellow commands
$ ionic plugin add cordova-plugin-dbmeter
$ npm install --save @ionic-native/db-meter
and used like this
import { DBMeter } from '@ionic-native/db-meter';
constructor(private dbMeter: DBMeter) { }
...
// Start listening
let subscription = this.dbMeter.start().subscribe(
data => console.log(data)
);
and i get same error as @yoke92 …
++++++++++++++++++++++++++
Error: No provider for DBMeter!
at NoProviderError.BaseError [as constructor] (http://localhost:8100/build/main.js:8347:34 )
at NoProviderError.AbstractProviderError [as constructor] (http://localhost:8100/build/main.js:52531:16 )
at new NoProviderError (http://localhost:8100/build/main.js:52562:16 )
at ReflectiveInjector_.throwOrNull (http://localhost:8100/build/main.js:98270:19 )
at ReflectiveInjector .getByKeyDefault (http://localhost:8100/build/main.js:98298:25 )
at ReflectiveInjector .getByKey (http://localhost:8100/build/main.js:98261:25 )
at ReflectiveInjector .get (http://localhost:8100/build/main.js:98070:21 )
at AppModuleInjector.NgModuleInjector.get (http://localhost:8100/build/main.js:53233:52 )
at CompiledTemplate.proxyViewClass.AppView.injectorGet (http://localhost:8100/build/main.js:98812:45 )
at CompiledTemplate.proxyViewClass.DebugAppView.injectorGet (http://localhost:8100/build/main.js:99054:49 )
@yoke92 …
I found the solution …
just add providers like this:
@Component({
selector: 'page-dbmeter',
templateUrl: 'dbmeter.html',
providers: [DBMeter]
})
and this …
ionViewDidLoad() {
console.log('ionViewDidLoad DbmeterPage');
let timer = setInterval(() => {
// Start listening
let subscription = this.dbMeter.start().subscribe(
data => this.currentAmplitude = data
);
}, 100);
}
1 Like
Thanks!
Solved my problem too! been at it for 2 hours
MYuan
April 18, 2019, 1:17pm
5
I’m new in IONIC and want to build a DB meter app. Can I have you code as example?