anu*_*bis 5 angularjs cordova ionic-framework
我正在尝试在Ionic应用程序上使用安全存储(https://ionicframework.com/docs/v2/native/secure-storage/).
在我的控制器中:
.controller('ExampleCtrl', function ($scope, SecureStorage) {
var ss = new SecureStorage(
function () {
console.log('Success')
},
function (error) {
console.log('Error ' + error);
},
'my_app');
var key = 'aaa';
Run Code Online (Sandbox Code Playgroud)
错误:
ionic.bundle.js:26799错误:[$ injector:unpr]未知提供者:SecureStorageProvider < - SecureStorage < - ExampleCtrl
但它不知道SecureStorage提供商.
你知道我做错了什么吗?
请尝试这个:
.controller('ExampleCtrl', function ($scope) {
var ss = new cordova.plugins.SecureStorage(
function () {
console.log('Success');
},
function (error) {
console.log('Error ' + error);
},
'my_app');
});
Run Code Online (Sandbox Code Playgroud)
因此,从控制器参数中删除 SecureStorage 并添加cordova.plugins.到第二行。
并且不要忘记安装插件(当然):
ionic plugin add cordova-plugin-secure-storage --save
Run Code Online (Sandbox Code Playgroud)
现在您可以使用 上的函数ss,但不要使用您提供的链接中的文档,因为这是 Ionic 2 文档。使用插件文档代替:https://github.com/Crypho/cordova-plugin-secure-storage
| 归档时间: |
|
| 查看次数: |
732 次 |
| 最近记录: |