我正在研究离子2。
http://ionicframework.com/docs/v2/native/file/
https://github.com/apache/cordova-plugin-file#persistent
我已使用此命令ionic plugin add cordova-file-plugin
安装了文件插件但我不知道如何使用它。
任何使用离子2的演示,我应该从哪里开始。
我的要求是将用户名和密码保存到文件中,甚至他们关闭应该访问主页的应用程序,因为正确的用户名和密码存储在文件中。
如果用户输入了错误的用户名和密码,它也应该存储在文件中,但是他们应该只看到登录页面。
这是我的代码
import {Component} from '@angular/core';
import {NavController} from 'ionic-angular';
import {File} from 'ionic-native';
@Component({
templateUrl: 'build/pages/home/home.html'
})
export class HomePage {
private userName: any;
private password: any;
constructor(public navCtrl: NavController) {
this.userName = "Admin";
this.password = "Admin123";
}
createFile(dirEntry, fileName, isAppend) {
// Creates a new file or returns the file if it already exists.
dirEntry.getFile(fileName, {create: true, exclusive: false}, function(fileEntry) {
writeFile(fileEntry, null, isAppend);
}, onErrorCreateFile);
}
}
我在
writeFile
和onErrorCreateFile
上收到错误,我应该怎么做以解决打字稿中的错误。如何将我的用户名和密码存储到我的文件中如何检查它是否存储或不存储。