在我的 Ionic V4 离子应用程序中,我想将ion-label文本颜色设置为黑色,ion-input禁用黑色。
无论如何,我ion-input通过在我的global.scss.
.native-input[disabled] {
opacity: 10 !important;
}
Run Code Online (Sandbox Code Playgroud)
也想要同样的 for ion-labeldisabled ion-input。
我正在尝试将此 ionic 3 代码转换为 ionic 4,但我不知道 promise 如何在 ionic 4 上工作。我尝试查看文档,但找不到任何 promise 的解决方案
async generateAlert(header, message, ok, notOk): Promise<boolean> {
return new Promise((resolve, reject) => {
let alert = await this.alertController.create({
header: header,
message: message,
buttons: [
{
text: notOk,
handler: _=> reject(false)
},
{
text: ok,
handler: _=> resolve(true)
}
]
})
await alert.present();
});
}
Run Code Online (Sandbox Code Playgroud) 我有一个 auth 守卫,需要运行一个 api 调用来查看他们是否可以访问。我不相信从订阅中返回数据是可能的,但我还能怎么做?
我需要获取用户 ID,然后调用 api,然后根据 api 调用返回 true 或 false。
import { Injectable } from '@angular/core';
import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, Router } from '@angular/router';
import { Observable } from 'rxjs';
import { AuthService } from 'src/app/services/auth.service';
@Injectable({
providedIn: 'root'
})
export class TeamcheckGuard implements CanActivate {
success: boolean;
constructor(
private router: Router,
private authService: AuthService
) {}
// Checks to see if they are on a team for the current game they selected.
canActivate(next: ActivatedRouteSnapshot,state: RouterStateSnapshot): …Run Code Online (Sandbox Code Playgroud) 我正在创建 ionic 4 angular 应用程序,并为 iPhone 编写媒体查询。我正在编写 Iphone x 和 Iphone 6、7、8 plus 媒体查询,但 Iphone x 媒体查询也适用于 Iphone x 和 Iphone plus。如何相互区分?下面显示了我正在使用的媒体查询。
/* iphone 6+, 6s+, 7+, 8+ */
@media only screen and (min-device-width: 414px) and (max-device-height: 736px) and (-webkit-device-pixel-ratio: 3) {}
/* iphone X */
@media only screen and (min-device-width: 375px) and (max-device-height: 812px) and (-webkit-device-pixel-ratio: 3){}
Run Code Online (Sandbox Code Playgroud) 我想以弹出模式以编程方式打开 ionSelect。
@ViewChild('selectNotificationList') selectNotificationList: IonSelect;
Run Code Online (Sandbox Code Playgroud)
打开离子选择的方法是:
clickNotificationNumber() {
this.selectNotificationList.interface = 'popover';
this.selectNotificationList.open();
}
Run Code Online (Sandbox Code Playgroud)
HTML是:
<ion-card slot="end" class="langCard">
<ion-card-content>
<ion-select interface ="popover" (ionChange)="readNotification($event)" #selectNotificationList>
<ion-select-option *ngFor="let message of notificationList let notificationIndex = index" value="{{message.id}}">
{{message.notificationOptions.body}}</ion-select-option>
</ion-select>
</ion-card-content>
</ion-card>
Run Code Online (Sandbox Code Playgroud) 我已经构建了一个使用搜索栏过滤 *ngFor 数组的页面。当我在搜索栏中键入时,它的行为正常,但是当我删除或退格文本时,它不会更新。如果我从数据服务的静态列表中提取一个数组,而不是我从 ApolloQueryResult 中提取的数据,它会正常工作。任何帮助将不胜感激。
html
<ion-content padding>
<div *ngIf="loading">Loading...</div>
<div *ngIf="error">Error loading data</div>
<ion-toolbar>
<ion-searchbar [(ngModel)]="searchTerm" (ionChange)="setFilteredItems()" showCancelButton="focus"></ion-searchbar>
</ion-toolbar>
<ion-card *ngFor="let data of info">
<ion-card-content>
{{data.TypeOfNotification}}
</ion-card-content>
</ion-card>
</ion-content>
Run Code Online (Sandbox Code Playgroud)
ts
import { Component, OnInit } from '@angular/core';
import { Apollo } from 'apollo-angular';
import { ApolloQueryResult } from 'apollo-client';
import { QueryTodoService } from '../../services/query-todo.service';
import { Storage } from '@ionic/storage';
@Component({
selector: 'app-tab-to-do',
templateUrl: './tab-to-do.page.html',
styleUrls: ['./tab-to-do.page.scss'],
})
export class TabToDoPage implements OnInit {
info: any;
error: any; …Run Code Online (Sandbox Code Playgroud) 我想删除离子项目的点击效果。我使用了 --background-activated 和 --ripple-color 但什么也没发生。
.no-click{
--background-activated: transparent;
--ripple-color: transparent;
}
<ion-item class="no-click">
<ion-avatar slot="start">
<img [src]="img">
</ion-avatar>
<ion-label>{{name}}</ion-label>
</ion-item>
Run Code Online (Sandbox Code Playgroud)
如何消除离子项目的点击效果?
运行“ionic cordova prepare”时,network_security_config.xml 不会被创建,这会导致稍后在构建过程中出现错误。
我曾尝试更改 config.xml 中的资源文件路径,并按照https://github.com/ionic-team/starters/issues/758 中的建议删除和读取cordova android,但它们没有解决我的问题。
network_security.xml 文件应该由cordova 生成还是我需要手动创建?
我正在使用cordova-android 8.1.0。
I'm trying to do a very simple login in my Ionic 4 app. When a user logs in I set a token in storage. This is working.
I'm using an Auth Guard to check against one page in the app, so if the token is set in storage, the user can view the page. Otherwise they are redirected to the login page.
My problem is that I'm completely stuck in async hell; I just can't figure it out. I'm trying …
我需要使用离子框架(v4)从 android 应用程序打印 html 内容。我在官方文档中找到了cordova-plugin-printer,但我无法让它工作。根据docs,您只需稍后安装插件和包装器。
ionic cordova plugin add cordova-plugin-printer
npm install @ionic-native/printer
Run Code Online (Sandbox Code Playgroud)
然后当注入打印机对象时,我收到 NullInjector 错误
ERROR Error: Uncaught (in promise): NullInjectorError: StaticInjectorError(AppModule)[TabComprobantePage -> Printer]:
StaticInjectorError(Platform: core)[TabComprobantePage -> Printer]:
NullInjectorError: No provider for Printer!
NullInjectorError: StaticInjectorError(AppModule)[TabComprobantePage -> Printer]:
StaticInjectorError(Platform: core)[TabComprobantePage -> Printer]:
NullInjectorError: No provider for Printer!
at NullInjector.push../node_modules/@angular/core/fesm5/core.js.NullInjector.get (core.js:725)
at resolveToken (core.js:11917)
at tryResolveToken (core.js:11861)
at StaticInjector.push../node_modules/@angular/core/fesm5/core.js.StaticInjector.get (core.js:11763)
at resolveToken (core.js:11917)
at tryResolveToken (core.js:11861)
at StaticInjector.push../node_modules/@angular/core/fesm5/core.js.StaticInjector.get (core.js:11763)
at resolveNgModuleDep (core.js:20233)
at NgModuleRef_.push../node_modules/@angular/core/fesm5/core.js.NgModuleRef_.get (core.js:20904)
at resolveNgModuleDep (core.js:20233)
at …Run Code Online (Sandbox Code Playgroud) ionic4 ×10
angular ×4
cordova ×2
typescript ×2
ionic-native ×1
ionic2 ×1
javascript ×1
observable ×1
printing ×1
promise ×1