我正在尝试使用这个cordova插件https://github.com/litehelpers/Cordova-sqlcipher-adapter.
这是我的代码:
...
import { Platform } from 'ionic-angular';
declare var cordova;
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
constructor(platform: Platform) {
platform.ready().then(() => {
alert(cordova.plugins.sqlitePlugin);
});
}
Run Code Online (Sandbox Code Playgroud)
问题是,无论我做什么,sqlitePlugin总是undefined:/然而cordova.plugins是一个对象.
我也试过,alert((<any>window).plugins.sqlitePlugin);但结果是一样的.
我正在使用Nexus 5X Android 8设备.
我以这种方式安装了插件:ionic cordova plugin add cordova-sqlcipher-adapter --save作为标准的cordova插件.
任何帮助将是欣赏:)
我尝试了一些方法来禁用弹跳效果设置no-bounce属性到ion-content
<ion-content no-bounce></ion-content>
Run Code Online (Sandbox Code Playgroud)
并为离子内容添加样式以禁用反弹.仍然没有解决我的问题.
Access to XMLHttpRequest at 'API_URL' from origin 'http://localhost:8080' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
当我运行我的本地主机系统来访问服务器 API 时。它将生成令牌而不是我收到类似上述错误的错误。请帮我。
我在这里切换:
<ion-toggle (ionChange)="notify(value)"></ion-toggle>
Run Code Online (Sandbox Code Playgroud)
当我点击这个时我想调用方法notify通过参数传递toggle值.我如何获得切换值?
谢谢!
我在离子卷轴中有10个名字,但它像段落一样进入下一行.
这是我的.html代码.
<ion-scroll scrollX="true" style="width:100vw; height:50px" >
<ion-row class="headerChip">
<div *ngFor="let tabName of product_type; let idx = index" [ngClass]="showSelectedTabArray[idx].showSelectedTab ? 'headerChipGray' : 'headerChipGreen'">
<ion-chip (click)="changeData(tabName)">
<ion-label >{{tabName.languagename}}</ion-label>
<div></div>
</ion-chip>
</div>
</ion-row>
</ion-scroll>
Run Code Online (Sandbox Code Playgroud)
这是我的CSS
.headerChipGray{
ion-chip.chip.chip-md{
margin: 2px 2px 2px 2px;
border-radius: 10px;
border: 1px solid gray;
background: white;
}
ion-chip.chip.chip-ios{
margin: 2px 2px 2px 2px;
border-radius: 10px;
border: 1px solid gray;
background: white;
}
}
.headerChipGreen{
ion-chip.chip.chip-md{
margin: 2px 2px 2px 2px;
border-radius: 10px;
background: white;
color: #A80C50;
border: …Run Code Online (Sandbox Code Playgroud) 我尝试改变离子2中离子标题的颜色.
我有以下代码:
<ion-header>
<ion-navbar>
<ion-title primary>Title</ion-title>
</ion-navbar>
</ion-header>
Run Code Online (Sandbox Code Playgroud)
颜色ion-title不要改变.我尝试了几件事:
<ion-title color="primary">Title</ion-title>
<ion-title>
<p primary>Title</p>
</ion-title>
Run Code Online (Sandbox Code Playgroud)
第二个我的标题是正确的颜色,但标题很大.所以我在variables.scss中添加它:
$toolbar-ios-height: 5rem; // ios
$toolbar-md-height: 5rem; // android
Run Code Online (Sandbox Code Playgroud)
但没有任何改变.有人有解决方案吗?或者我是否必须使用p或h标签来改变颜色?
我需要根据用户的角色显示侧边菜单项.所以我检查app.html是否页面(角色)等于登录角色.但它在登录后不显示菜单内的项目,但在使用浏览器刷新按钮刷新应用程序后,它会显示正确的项目.我想问题是离子是缓存菜单视图,如果它是如此,我如何刷新应用程序以显示新的菜单项.
每次我使用其他用户/角色登录时,它都会根据之前的用户/角色显示菜单.
app.component.ts
constructor() {
this.initializeApp();
this.pages = [
{ title: 'Home', component: 'HomePage', icon: 'home', role: 5 },
{ title: 'Profile', component: 'ProfilePage', icon: 'person', role: 5 },
{ title: 'Account', component: 'AccountPage', icon: 'home', role: 5 },
{ title: 'Search Employee', component: 'AtlasemployeehomePage', icon: 'home', role: 4 }
];
}
Run Code Online (Sandbox Code Playgroud)
app.html
<ion-list>
<div *ngFor="let p of pages">
<button menuClose ion-item *ngIf="p.role == role" (click)="openPage(p)">
<ion-icon name="{{p.icon}}" style="margin-right:10%"></ion-icon> {{p.title}}
</button>
</div>
<button menuClose ion-item (click)="presentLogout()">
<ion-icon name="log-out" style="margin-right:10%"></ion-icon> Logout …Run Code Online (Sandbox Code Playgroud) 我有一个模板表单,模板标记中包含以下代码
<form [formGroup]="modalFG">
...
<ion-item *ngIf="isChangeStatus()">
<ion-select formControlName="jobStatus"
(ionChange)="jobStatusChangeHandler($event)">
<ion-option value=4>Success</ion-option>
<ion-option value=5>Failure</ion-option>
<ion-option value=6>Terminated</ion-option>
<ion-option value=8>Inactive</ion-option>
</ion-select>
</ion-item>
</form>
Run Code Online (Sandbox Code Playgroud)
在Typescript中我已经指定了一个值,但是我无法通过这个错误.
错误:必须为名称为'jobStatus'的表单控件提供值.
有人能告诉我我做错了什么吗?
...
private modalFG:FormGroup;
private jobStatus:number;
constructor(
private navParams:NavParams,
private view:ViewController,
private fb: FormBuilder,
...
) {
this.changeStatus = false;
this.modalFG = fb.group({
comment: ['', Validators.required],
jobStatus: this.jobStatus
});
}
private ionViewWillLoad():void {
const data = this.navParams.get('data');
this.modalFG.setValue({'jobStatus': this.jobStatus});
}
private jobStatusChangeHandler(ev:any) {
console.log(ev);
}
private isChangeStatus():boolean {
return this.changeStatus;
}
Run Code Online (Sandbox Code Playgroud)
我也有提交的按钮处理程序:
this.exitData.jobStatus = this.modalFG.get('jobStatus').value;
this.view.dismiss(this.exitData);
Run Code Online (Sandbox Code Playgroud)
这是完整的错误消息:
Error: …Run Code Online (Sandbox Code Playgroud) 我试图添加ion-inputfor maxlength,max属性但它没有按预期工作.
<ion-input type="number" placeholder="*" maxlength="1"></ion-input>
<ion-input type="number" placeholder="*" max="1"></ion-input>
Run Code Online (Sandbox Code Playgroud)
有谁知道相同的解决方案?
谢谢
我正在使用ionic 3 android build apk并尝试从文件中添加图像:///storage/emulated/0/data/io.ionic.vdeovalet/cache/image.jpeg
takePicture(sourceType) {
try {
// Create options for the Camera Dialog
var options = {
quality: 100,
destinationType: this.camera.DestinationType.FILE_URI,
encodingType: this.camera.EncodingType.JPEG,
sourceType: sourceType,
};
this.camera.getPicture(options).then((imagePath) => {
// Special handling for Android library
if (this.platform.is('android') && sourceType ===
this.camera.PictureSourceType.PHOTOLIBRARY) {
this.filePath.resolveNativePath(imagePath)
.then(filePath => {
let correctPath = filePath.substr(0, filePath.lastIndexOf('/') + 1);
let currentName = imagePath.substring(imagePath.lastIndexOf('/') + 1,
imagePath.lastIndexOf('?'));
this.copyFileToLocalDir(correctPath, currentName, this.createFileName());
this.lastImage = filePath;
});
} else {
var currentName = imagePath.substr(imagePath.lastIndexOf('/') …