Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70429

IOnic 4 with SQLite data implementation. pls clarify

$
0
0

@rahimhaji wrote:

Dear Friends,

Iam following youtube lesson (https://www.youtube.com/watch?v=BOXZBzBwfBQ) and learning Ionic4 with SQLIte local data storing. Iam using same exactly code as below.

app.module.ts

import { NgModule } from ‘@angular/core’;
import { BrowserModule } from ‘@angular/platform-browser’;
import { RouteReuseStrategy } from ‘@angular/router’;

import { IonicModule, IonicRouteStrategy } from ‘@ionic/angular’;
import { SplashScreen } from ‘@ionic-native/splash-screen/ngx’;
import { StatusBar } from ‘@ionic-native/status-bar/ngx’;

import { AppComponent } from ‘./app.component’;
import { AppRoutingModule } from ‘./app-routing.module’;
import {SQLite} from ‘@ionic-native/sqlite/ngx’
import { from } from ‘rxjs’;

@NgModule({
declarations: [AppComponent],
entryComponents: ,
imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule],
providers: [
StatusBar,
SplashScreen,
SQLite,
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy }
],
bootstrap: [AppComponent]
})
export class AppModule {}

home.page.ts

import { Component } from ‘@angular/core’;
import {SQLite, SQLiteObject} from ‘@ionic-native/sqlite/ngx’;
import { from } from ‘rxjs’;

@Component({
selector: ‘app-home’,
templateUrl: ‘home.page.html’,
styleUrls: [‘home.page.scss’],
})
export class HomePage {

constructor( public sqlite:SQLite) {
this.sqlite.create(
{
name:‘ex.db’,
location:‘default’
}
).then(
(db : SQLiteObject) => {
console.log(JSON.stringify(db))
this.addHero(db)
}
)
}

addHero(dbObj : SQLiteObject){

}

printAllHeros(dbObj : SQLiteObject){

}

}

**When i compile using ionic serve, **
it gives below error:

core.js:6014 ERROR Error: Uncaught (in promise): TypeError: Cannot read property ‘then’ of undefined
TypeError: Cannot read property ‘then’ of undefined
at new HomePage (home.page.ts:18)
at createClass (core.js:31987)
at createDirectiveInstance (core.js:31807)
at createViewNodes (core.js:44210)
at createRootView (core.js:44082)
at callWithDebugContext (core.js:45632)
at Object.debugCreateRootView [as createRootView] (core.js:44848)
at ComponentFactory_.create (core.js:30788)
at ComponentFactoryBoundToModule.create (core.js:25731)
at ViewContainerRef_.createComponent (core.js:30995)
at resolvePromise (zone-evergreen.js:797)
at resolvePromise (zone-evergreen.js:754)
at zone-evergreen.js:858
at ZoneDelegate.invokeTask (zone-evergreen.js:391)
at Object.onInvokeTask (core.js:39680)
at ZoneDelegate.invokeTask (zone-evergreen.js:390)
at Zone.runTask (zone-evergreen.js:168)
at drainMicroTaskQueue (zone-evergreen.js:559)

Please help me to solve this issue. i want to create db, add and delete the data.

Please note that iam new to ionic4 with sqllite. I know html and javascript. Basicallly iam a AS# programmer.

Thanks and Regards,

Syed Abdul Rahim

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70429

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>