alert在返回上一页之前,如何显示用户必须关闭的内容?我正在使用标准<ion-navbar *navbar> 箭头按钮.
我尝试像这样挂钩NavController事件ionViewWillLeave,但它不起作用:
ionViewWillLeave() {
let alert = Alert.create({
title: 'Bye',
subTitle: 'Now leaving',
buttons: ['OK']
});
this.nav.present(alert);
}
Run Code Online (Sandbox Code Playgroud)
这会显示警报,但一旦关闭就不会返回.如果我发表评论,后退按钮工作正常.
我有一个全新的应用程序使用ng-cli创建这个非常简单的代码^^
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
constructor(private my: string) {}
}
Run Code Online (Sandbox Code Playgroud)
而且我已进入控制台了
EXCEPTION:没有String的提供者!
我没有在代码中看到任何错误,所以有什么不对!
在ng-book中,我可以阅读
export class Article {
title: string;
link: string;
votes: number;
constructor(title: string, link: string, votes?: number) {
this.title = title;
this.link = link;
this.votes = votes || 0;
}
}
Run Code Online (Sandbox Code Playgroud)
https://github.com/Microsoft/TypeScriptSamples/blob/master/greeter/greeter.ts
我仍然对rxjs如何工作感到困惑.
我正在构建一个Ionic应用程序,它向我的服务器发出请求并期望json.我已经成功订阅了http.post并获取了我需要的数据.
但是现在我的问题是我需要在我从Storage获得的http请求中传递一个auth令牌.这是一个问题,因为我需要等到存储准备就绪,然后在调用http.post请求之前从中获取我的令牌值.
这是我试图获取我的json数据的地方
getPlanograms() {
//API URL
let requestURL = 'https://myapiurlhere';
let headers = new Headers({'Content-Type': 'application/json'});
return this.storage.ready().then(() => {
return this.storage.get('id_token').then((val) => {
headers.append('Authorization', 'Bearer ' + this.authCredentials.token);
let options = new RequestOptions({headers: headers});
return this.http.post(requestURL, {}, options)
.map(response => <Planogram[]>response.json());
})
});
}
Run Code Online (Sandbox Code Playgroud)
从这里开始调用
ionViewDidLoad (){
this.merchandisingDataService.getPlanograms()
.subscribe(Planogram => this.planograms = Planogram);
}
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试这样做时,我得到以下错误
"承诺"类型中不存在"订阅"属性.
实现目标的最佳方式是什么?
我需要将状态栏文本颜色更改为黑色(或黑色).但是Cordova插件不支持.但我已经看到Android本机设备上有一个方法,如下所示.我们可以在Ionic 3上做同样的事情.应用程序呢?
<style name="statusBarStyle" parent="@android:style/Theme.DeviceDefault.Light">
<item name="android:statusBarColor">@color/status_bar_color</item>
<item name="android:windowLightStatusBar">false</item>
</style>
Run Code Online (Sandbox Code Playgroud) 我有一个Ionic页面,它查询FirebaseListObservable以在ion-searchbar上进行动态搜索.它适用于Angularfire2@4.0.0-rc.0和firebase@4.5.0.在升级新版本AngularFire 5.0后,我遇到了一个关于FirabaseListObservable没有从新Api导出的问题.
import { Component } from '@angular/core';
import { IonicPage, NavParams, ViewController } from 'ionic-angular';
import {AngularFireDatabase, FirebaseListObservable} from 'angularfire2/database';
import { Observable} from 'rxjs';
import { Response } from '@angular/http';
@IonicPage()
@Component({
selector: 'page-modal-groups',
templateUrl: 'modal-groups.html'
})
export class ModalGroupsPage {
groups: FirebaseListObservable<any>;
constructor(public navParams: NavParams,
public viewCtrl:ViewController,
public afDatabase: AngularFireDatabase) {
}
getItems = (ev: any) : Observable<Response> => {
this.groups = this.afDatabase.list('/Groups', {
query:{
orderByChild: 'namelower',
startAt: (ev.target.value),
endAt: (ev.target.value + '\uf8ff')
}
} …Run Code Online (Sandbox Code Playgroud)firebase firebase-realtime-database angularfire2 ionic3 angular
我正在使用离子模态,我想调整我的模态到全屏,不是所有模态但只有1模态,但无法实现这一点,因为离子本身是使用!important属性设置宽度/高度属性.我试过这样的事情
@media only screen and (orientation: landscape) {
ion-modal {
.modal-wrapper {
position: absolute;
top: 0 !important;
left: 0 !important;
display: block;
width: 100% !important;
height: 100% !important;
}
}
}
Run Code Online (Sandbox Code Playgroud)
当我把它放在页面的范围内时,它没有显示任何效果,但当我把它放在页面的范围之外时,它会改变app中所有模态的宽度/高度.我已经在网上搜索并尝试了很多解决方案,但没有一个有效(或者我可能无法理解它).在这方面的任何帮助将受到高度赞赏.谢谢
我有一个像下面这样的异步方法.它[ts] 'await' expression is only allowed within an async function.在这里显示错误await userProfile.set({.你能告诉我怎么解决它吗?
注意:也许是因为我试图在promise里面打电话observable.任何线索?
async loginWithGoogle(): Promise<void> {
const result = await this.afAuth.auth.signInWithPopup(new firebase.auth.GoogleAuthProvider());
const userId: string = result.uid;
const userProfile: AngularFirestoreDocument<UserProfile> = this.fireStore.doc(`userProfile/${userId}`);
const userProfiles: AngularFirestoreCollection<UserProfile> = this.fireStore.collection('userProfile/', ref => ref.where('email', '==', result.email));
const userProfiles$: Observable<UserProfile[]> = userProfiles.valueChanges();
userProfiles$.subscribe(res => {
if (res == null) {
await userProfile.set({ //here it shows error
id: userId,
email: result.email,
creationTime: moment().format(),
lastSignInTime: moment().format()
});
} …Run Code Online (Sandbox Code Playgroud) 以何种方式使用与离子命令行界面一起使用的环境特定参数ionic build android --prod --device,以便根据环境(例如生产和开发)对javascript/typescript代码进行区分?
我应该用process.env.IONIC_ENV吗?或者我可以通过哪种方式查询这种区别?
我试图遵循这个教程:https://www.youtube.com/watch?v = SOOjamH1bAA.但我甚至无法开始,因为从它的外观来看,我的项目没有config.xml文件,我尝试在线查找文档,它没有说明它,我也尝试搜索如何生成它,没找到任何东西,为什么我错过了这个config.xml?如何生成这个文件?这是一个显示它应该是的位置的链接,它不在那里:
继承人离子信息输出:
Ionic: ionic (Ionic CLI) : 4.1.1 (C:\Users\Publio\AppData\Roaming\npm\node_modules\ionic) Ionic Framework : ionic-angular 3.9.2 @ionic/app-scripts : 3.1.11 System: NodeJS : v8.11.3 (C:\Program Files\nodejs\node.exe) npm : 6.3.0 OS : Windows 10
Run Code Online (Sandbox Code Playgroud) 我正在使用cordova-plugin-advanced-http插件进行API调用,所有JSON启用的API工作正常,但我有一个XML嵌入式API在Postman中工作正常,但我从离子调用它的param没有得到服务器端.
下面是我的XML API代码:
类型1:
let headers = {
"Content-type": 'text/xml; charset=utf-8',
"Authorization": token,
};
let xmlBody =
'<ServiceRequest>' +
'<CaseNumber>' + caseNumber +
'</CaseNumber>' +
'</ServiceRequest>'
this.httpPlugin.setDataSerializer('utf8');
this.httpPlugin.post('https://test.com/Service', xmlBody, headers).then((response) => {
console.log("XML Response : ", JSON.stringify(response.data));
xml2js.parseString(response.data, function (err, result) {
console.log("XML parser success:", result);
console.log("XML parser error:", err);
if (result) {
resolve(result);
} else {
reject(err);
}
});
}).catch(error => {
if (error.status == 403) {
console.log("Token expired : " + JSON.stringify(error)); …Run Code Online (Sandbox Code Playgroud) ionic3 ×10
angular ×6
typescript ×3
angularfire2 ×2
cordova ×2
ionic2 ×2
javascript ×2
rxjs ×2
xml ×2
android ×1
cordova-plugin-advanced-http ×1
css ×1
firebase ×1
html ×1
ionic-native ×1
ios ×1
sass ×1