我正在尝试,ngCordova但cordova.file.documentsDirectory财产是null.
我也曾尝试结合使用的ngCordova与requestFileSystem,不过,该文件不保存在"下载的".
我的代码示例:
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(directory) {
var fileTransfer = new FileTransfer();
fileTransfer.download(
encodeURI("http://example.com/sample.pdf"),
directory.root.nativeURL + 'sample.pdf',
function(entry) {
console.log("download complete: " + entry.fullPath);
},
function(error) {
console.log("download error source " + error.source);
console.log("download error target " + error.target);
console.log("upload error code" + error.code);
},
false
);
}, function(err){console.error(err)});
Run Code Online (Sandbox Code Playgroud)
谢谢.
考虑到我的关系数据库背景,我正在努力了解IONIC 2中的数据存储。阅读了许多有关此问题的教程和文章之后,我对如何进行有一个一般性的了解,但是希望我能对我有所帮助。正确的轨道上。我热衷于使用NoSQL,因此许多使用Ionic的SQL Storage的教程都无济于事。
到目前为止,我倾向于使用Ionic 2的Storage或Pouch DB。我看不出有什么区别。当作为本机应用程序运行时,它们都使用SQLite,或者在IndexDB或WebSQL上使用回退。
这里推荐的做法是什么?
<ion-header>
<ion-navbar hideBackButton>
<ion-title>
Test
</ion-title>
<button menuToggle>
<ion-icon name="menu"></ion-icon>
</button>
</ion-navbar>
</ion-header>
我可以拖动和关闭菜单,但菜单按钮没有添加到导航栏.
我已经安装了Cordova网络插件,但似乎无法检查网络连接.
这是我的代码
import { Network } from 'ionic-native';
declare var navigator: any;
declare var Connection: any;
this.platform.ready().then(() => {
if(Network.connection === 'none') {
let alert = this.alertCtrl.create({
title: "Internet Connection",
subTitle:"Please Check Your Network connection",
buttons: [{
text: 'Ok',
handler: () => {
this.platform.exitApp();
}
}]
});
alert.present();
}
});
}
Run Code Online (Sandbox Code Playgroud)
我收到警告信息
Native:deviceready在2000ms内没有激活.当插件处于不一致状态时,可能会发生这种情况.尝试从插件中删除插件/并重新安装它们.
我怎么能解决这个问题?
我有点击它的项目列表我需要做一些动作.我也有这些动作的滑动菜单.当我滑动它并单击它时也会触发点击`ion-item-sliding.滑动打开时是否有可能以某种方式阻止点击?
<ion-item-sliding *ngFor="let event of events" (click)="showModalInfo(event)">
<ion-item>
<h2>{{ event['Event type'] }}</h2>
</ion-item>
<ion-item-options side="right">
<button ion-button color="light" icon-left (click)="showDescription(event)">
<ion-icon name="ios-more"></ion-icon>
More
</button>
</ion-item-options>
</ion-item-sliding>
Run Code Online (Sandbox Code Playgroud) 按下硬件后退按钮时如何防止默认导航?我试过了registerBackButtonAction,但是它覆盖了我不想要的每个页面中的后退按钮的行为.
这也没有帮助.
document.addEventListener("backbutton", (event) => {
event.preventDefault();
}, false);
Run Code Online (Sandbox Code Playgroud) 在以下代码中,该fileTransfer.upload()方法将文件上载到远程服务器.但是我们如何发送额外的数据,例如谁上传,如发送用户ID.
public uploadImage() {
// Destination URL
var url = "http://yoururl/upload.php";
// File for Upload
var targetPath = this.pathForImage(this.lastImage);
// File name only
var filename = this.lastImage;
var options = {
fileKey: "file",
fileName: filename,
chunkedMode: false,
mimeType: "multipart/form-data",
params : {'fileName': filename}
};
const fileTransfer = new Transfer();
this.loading = this.loadingCtrl.create({
content: 'Uploading...',
});
this.loading.present();
// Use the FileTransfer to upload the image
fileTransfer.upload(targetPath, url, options).then(data => {
this.loading.dismissAll()
this.presentToast('Image succesful uploaded.');
}, err => {
this.loading.dismissAll() …Run Code Online (Sandbox Code Playgroud) 如何在离子2侧面菜单中添加Logout选项卡?如果您已登录,则表明您正在使用DashboardPage.现在我有一个菜单项"Logout",它只是带我到主页.这是app.component.ts中包含所有菜单项的pages数组:
this.pages = [
{title: 'Dashboard', component: DashboardPage},
...
{title: 'Logout', component: HomePage}
];
Run Code Online (Sandbox Code Playgroud)
但现在我需要在注销后面添加逻辑,而不仅仅是页面切换.当我点击Logout选项卡而不是仅转到HomePage时,是否可以调用函数logout()?
编辑:
这是openPage函数:
openPage(page) {
this.nav.setRoot(page.component);
}
Run Code Online (Sandbox Code Playgroud) 嗨想要这样的东西,并将css分配给每个div和地址块.可能吗???
let alert = this.alertCtrl.create({
title: 'Contact Us',
subTitle: `
<div class="address-block pp-notes-row">
<address></address>
</div>
`,
buttons: ['OK'],
cssClass: `
.alert-wrapper {
width: 100%
}
.address-block {
text-align: left;
}
`
});
alert.present();
Run Code Online (Sandbox Code Playgroud) 我收到以下错误消息
[ts] Property type 'url' does not exist on type 'Event'.
any
Run Code Online (Sandbox Code Playgroud)
这是我使用的TypeScript(JavaScript)
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
var ref = window.open(url, '_blank', 'location=yes');
ref.addEventListener('loadstart', function(event) { });
ref.addEventListener('loadstop', function(event) { });
ref.addEventListener('loaderror', function(event) { alert( event.url ) });//Property type 'url' does not exist on type 'Event'.
}
Run Code Online (Sandbox Code Playgroud)
这是我的进口
import { Component } from '@angular/core';
import { NavController, Platform } from 'ionic-angular';
import { InAppBrowser } from '@ionic-native/in-app-browser';
import { Event } from '@angular/router';
Run Code Online (Sandbox Code Playgroud)
请帮忙!
ionic-framework ×10
ionic2 ×7
angular ×5
javascript ×3
typescript ×3
ionic3 ×2
android ×1
cordova ×1
download ×1
file-upload ×1
pouchdb ×1