离子2错误:尝试访问外部组件的功能

时间:2017-01-08 16:38:46

标签: angular typescript ionic2

我试图将一个离子buit-in组件注入我的主要组件,所以我可以从我的主要组件的任何功能调用它。

这是我的主要内容:

import { Component } from '@angular/core';
import { Platform , LoadingController} from 'ionic-angular';
import { StatusBar, Splashscreen,NativeStorage } from 'ionic-native';



@Component({
  templateUrl: 'app.html',
  providers:[NativeStorage]
})
export class MyApp {
  constructor(platform: Platform,private loadingCtrl: LoadingController,public settings: NativeStorage) {
    platform.ready().then(() => {
      // Okay, so the platform is ready and our plugins are available.
      // Here you can do any higher level native things you might need.
      StatusBar.styleDefault();
      Splashscreen.hide();
      this.loadingCtrl.create({content:'loading..'}).present();
    });
    this.isSetup();
  }

  isSetup(){
    this.settings.getItem('ok').then(
      data => console.log(data),
      error => console.log(error)
    )
  }


}

PS 1:我已经安装了本机存储插件;

PS 2:我收到了错误:Property' getItem'在类型' NativeStorage'中不存在但是当我直接使用NativeStorage.getItem调用组件时......它的工作原理我认为语法中存在问题。

谢谢。

0 个答案:

没有答案