我有一个带有angular2应用程序的nativescript for android,我想利用nativescript-sqlite的离线存储功能.问题是我得到以下异常:
Failed to find module: "nativescript-sqlite", relative to: /app/tns_modules/
Run Code Online (Sandbox Code Playgroud)
在下面的行:
var Sqlite = require("nativescript-sqlite");
Run Code Online (Sandbox Code Playgroud)
我使用以下命令安装插件
tns插件添加nativescript-sqlite
我创建了一个带有角度服务的db.service.ts文件,其内容如下:
import {Injectable} from "@angular/core";
import {Config} from "../config";
import {Observable} from "rxjs/Rx";
import "rxjs/add/operator/do";
import "rxjs/add/operator/map";
import {Profile} from "../profile/profile";
var Sqlite = require("nativescript-sqlite");
@Injectable()
export class DbService {
database: any;
constructor() {
(new Sqlite("gtel.db")).then(db => {
this.database = db;
db.resultType(Sqlite.RESULTSASOBJECT);
this.database.execSQL("CREATE TABLE IF NOT EXISTS profile (id INTEGER PRIMARY KEY AUTOINCREMENT," +
" username TEXT, idnumber TEXT, firstname TEXT, lastname …
Run Code Online (Sandbox Code Playgroud) 我只是想知道如何在新的angularjs 2.0中创建http请求以及如何将此服务挂钩到控制器.
谢谢.