我正在尝试使用ionic / file-chooser插件来上传文件。一切都很完美,直到我没有要求上传doc或pdf文件。我正在使用离子3.12.0和科尔多瓦7.0.1。
const fileTransfer: FileTransferObject = this.transfer.create();
let options: FileUploadOptions = {
fileKey: 'files0',
fileName: 'name.jpg',
params: {
Authkey: this.CS.auth_key,
Token: this.CS.token,
group_id: this.CS.activeGroupId,
Userid: this.CS.userId
}
};
this.fileChooser.open()
.then(uri => {
this.CS.show_loader();
//alert(uri );
this.file.resolveLocalFilesystemUrl(uri)
.then((files)=> {
alert(JSON.stringify(files, null, 4));
}).catch((err) => {
alert(JSON.stringify(err, null, 4));
});
//let name = uri.split("/");
//options.fileName = name[name.length - 1];
// alert(options.fileName);
fileTransfer.upload(uri, this.CS.base_url + 'groups/uploadChat', options)
.then((data) => {
this.CS.hide_loader();
this.res = data;
//alert(JSON.stringify(data, null, 4));
let d = JSON.parse(this.res.response);
if(d.status …Run Code Online (Sandbox Code Playgroud) 我建立了一个模态页面,就像一个自定义警报.我需要在警报中添加一个图像,所以我按照这个来制作自定义警报窗口:如何在离子2中进行自定义警报?
问题是模态被拉伸以适应屏幕高度.有没有办法让它始终适合自己的内容高度?那么高度是它必须的最小值?
这是页面的scss:
modal-alert.scss
page-modal-alert {
background-color: rgba(0, 0, 0, 0.5);
ion-content.content{
top: 10%;
left: 10%;
width: 80%;
height: 375px; // <-- fixed
//height: 75%; // <-- will stretch to screen size
border-radius: 10px;
.scroll-content {
border-radius: 20px;
}
}
}
Run Code Online (Sandbox Code Playgroud)
页面模板:
modal-alert.html
<ion-content padding>
<img src="assets/img/20pointsBox.png">
<div>
<p>{{ text }}</p>
<ion-buttons>
<button full ion-button color="secondary" (click)="dismiss()">
OK
</button>
</ion-buttons>
</div>
</ion-content>
Run Code Online (Sandbox Code Playgroud)
编辑:
当上面的类设置为模态时,它看起来像这样(但是带有图像,文本和一个按钮):
文本和图像内容是动态的,我在运行时更改它们,因此有时此模式的固定高度与其内容的实际高度不匹配.
有没有办法让模态高度适合其内容的总高度?
我试图创建一个离子应用程序,当我在离子创建器中将页面链接在一起时,.ts文件出现错误,如下所示:
typescript: src/pages/home/home.ts, line: 4
Individual declarations in merged declaration 'HomePage' must be all exported or all local.
L3: import { NotificationsPage } from '../notifications/notifications';
L4: import { HomePage } from '../home/home';
L5: import { MyPatientsPage } from '../my-patients/my-patients';
Run Code Online (Sandbox Code Playgroud)
以下是我的.ts文件中的代码:
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { NotificationsPage } from '../notifications/notifications';
import { HomePage } from '../home/home';
import { MyPatientsPage } from '../my-patients/my-patients';
import { AllPatientsPage } from '../all-patients/all-patients';
import { LoginPage } …Run Code Online (Sandbox Code Playgroud) 我遵循此处找到的答案:Ionic 2 Alert定制
但是我找不到必须设置样式的所有其他类或元素,因此警报看起来像我想要的。
我编辑了代码,如下所示:
app.scss:
.alertCustomCss {
background-color: color($colors, dark, base);
color: white;
button {
color: white !important;
}
}
Run Code Online (Sandbox Code Playgroud)
ts:
const alert = this.alertCtrl.create({
title: title,
subTitle: msg,
buttons: ['OK'],
cssClass: 'alertCustomCss'
});
alert.present();
Run Code Online (Sandbox Code Playgroud)
但这使所有文本变为白色,替换了包含弹出窗口的模式页面的透明性,并将其设置为设置“背景色”(因此,不再显示称为弹出窗口的页面)。该按钮的文本设置为白色。
请注意,弹出窗口周围的背景不再透明。
问题是如何设置文本占位符而不是整个页面的背景色?要使用哪些CSS属性?
更广泛的问题:可以设置样式的警报弹出窗口有哪些元素(css类或指令)?标题文字颜色,内容文字字体等。
这是我的代码:
<ion-content padding text-center>
<img src="../assets/img/logo.png" width="200" class="logo" />
</ion-content>
<ion-footer>
<ion-row no-padding>
<ion-col col-6 align-self-stretch>
<button ion-button full>Button</button>
</ion-col>
<ion-col col-6 align-self-stretch>
<button ion-button full>Button</button>
</ion-col>
</ion-row>
</ion-footer>
Run Code Online (Sandbox Code Playgroud)
我需要删除ion-row和ion-col的填充/边距.我试过谷歌搜索但我没有运气.我也是Ionic的新手.TIA!
这是截图:
我需要实现这个目标:
我正在尝试使用firebase来获取分析事件,但我得到的只是session_start事件。我正在使用Firebase 离子插件。
这是我的代码:
constructor(public navCtrl: NavController, private nav: NavController,
private firebaseAnalytics: FirebaseAnalytics) {
this.firebaseAnalytics.setEnabled(true);
this.firebaseAnalytics.logEvent('home_page_viewed', {page: "dashboard"})
.then((res: any) => console.log(res))
.catch((error: any) => console.error(error));
}
Run Code Online (Sandbox Code Playgroud)
因此,我希望在Firebase控制台中看到一个名为“ home_page_viewed”的事件,但我没有看到此事件。我所看到的只是session_start事件。
有人知道我该怎么办?
我正在尝试显示图像从画廊到img标签。但是图像未显示在img标签上。但是它正在与PhotoViewer。下面是我的代码。
options: CameraOptions = {
quality: 100,
destinationType: this.camera.DestinationType.FILE_URI,
encodingType: this.camera.EncodingType.JPEG,
sourceType: this.camera.PictureSourceType.PHOTOLIBRARY
//mediaType: this.camera.MediaType.PICTURE
}
Run Code Online (Sandbox Code Playgroud)
用拍摄的图像
this.camera.getPicture(this.options).then((imageData) => {
alert(imageData)
this.photoViewer.show(imageData);
this.captureDataUrl=imageData;
}, (err) => {
// Handle error
});
Run Code Online (Sandbox Code Playgroud)
在HTML中
<img [src]="captureDataUrl" *ngIf="captureDataUrl"/>
Run Code Online (Sandbox Code Playgroud)
如果我将sourceType用作相机(sourceType: this.camera.PictureSourceType.CAMERA),它也可以工作,它将在img标签上显示图像,但是如果我将sourceType用作,则无法正常工作sourceType: this.camera.PictureSourceType.PHOTOLIBRARY 。请帮忙
在Ionic的旧版本1中,我能够构建按日期分组的事件列表,如下所示:
<ion-list ng-repeat="(key, value) in events| groupBy: 'event.date'">
<div class="item item-divider" ng-if="value">
{{ ::key | event.date }}
</div>
<ion-item class="item" ng-repeat="event in value track by event.event.event_id">
{{ ::event.event.title }}
</ionic-item>
</ion-list>
Run Code Online (Sandbox Code Playgroud)
虽然事件对象看起来像这样(事件#1和#3共享相同的日期):
{
"events": [
{
"id": 1,
"date": "2017-12-26",
"title": "First event"
},
{
"id": 2,
"date": "2017-12-30",
"title": "Second event"
},
{
"id": 3,
"date": "2017-12-26",
"title": "Third event"
},
{
"id": 4,
"date": "2017-12-31",
"title": "Last event"
}
]
}
Run Code Online (Sandbox Code Playgroud)
这给了我一个存储在"事件"对象中的事件列表,这些事件按"event.date"分组.所以在同一天的所有事件都按项目分隔符分组:
+--------------+
+ 2017-12-26 +
+--------------+
| …Run Code Online (Sandbox Code Playgroud) 简要说明:尝试在home.html页面上实现popover控制器.试图按照文档但仍然无法完成.
我在popover.ts旁边创建了页面,home.ts但是当我尝试导入时home.ts,它就是说Cannot find module 'popover'.
我究竟做错了什么 ?
home.ts
import { PopoverController } from 'ionic-angular';
import { PopoverPage } from 'popover';
@Component({})
class MyPage {
constructor(public popoverCtrl: PopoverController) {}
presentPopover(myEvent) {
let popover = this.popoverCtrl.create(PopoverPage);
popover.present({
ev: myEvent
});
}
}
Run Code Online (Sandbox Code Playgroud)
popover.ts
import { Component } from '@angular/core';
import { ViewController } from 'ionic-angular';
@Component({
template: `
<ion-list>
<ion-list-header>Ionic</ion-list-header>
<button ion-item (click)="close()">Learn Ionic</button>
<button ion-item (click)="close()">Documentation</button>
<button ion-item (click)="close()">Showcase</button>
<button …Run Code Online (Sandbox Code Playgroud) 遵循以下有关通过Cordova使用OAuth Provider进行身份验证的说明,在我的离子应用程序构建中遇到上述错误。
在网络上进行搜索后,我最终获得了以下repo ionic-plugin-deeplinks。
似乎不再被维护。还有其他人有这个问题吗?有什么办法吗?
ionic info cli软件包:(/ usr / local / lib / node_modules)
@ionic/cli-utils : 1.19.0
ionic (Ionic CLI) : 3.19.0
Run Code Online (Sandbox Code Playgroud)
全局软件包:
cordova (Cordova CLI) : 7.1.0
Run Code Online (Sandbox Code Playgroud)
本地套餐:
@ionic/app-scripts : 3.1.2
Cordova Platforms : ios 4.5.4
Ionic Framework : ionic-angular 3.9.2
Run Code Online (Sandbox Code Playgroud)
系统:
ios-deploy : 1.9.2
Node : v8.9.1
npm : 5.5.1
OS : macOS Sierra
Xcode : Xcode 9.2 Build version 9C40b
Run Code Online (Sandbox Code Playgroud) ionic-framework ×10
angular ×5
ionic3 ×5
ionic2 ×4
css ×3
cordova ×2
firebase ×2
javascript ×2
typescript ×2
android ×1
angularfire ×1
angularfire2 ×1
file-upload ×1
image ×1
ionic-native ×1
sass ×1