按下硬件后退按钮时如何防止默认导航?我试过了registerBackButtonAction,但是它覆盖了我不想要的每个页面中的后退按钮的行为.
这也没有帮助.
document.addEventListener("backbutton", (event) => {
event.preventDefault();
}, false);
Run Code Online (Sandbox Code Playgroud) 是否可以访问push notification离子2中的内容并在通知到达时执行一堆代码event fire?
我在这里经历过SO问题.但我无法得到这个错误试图建议的内容.请帮我解决这个问题.
最后,HIGHER MODULE意味着哪个模块.因为我是新手,所以这就是为什么不正确.
mycode的:
app.module.ts
@NgModule({
declarations: [
MyApp,
UsersPage,
ReposPage,
OrganisationsPage,
UserDetailsPage,
LoginPage
],
imports: [
BrowserModule,
HttpModule,
IonicModule.forRoot(MyApp),
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
LoginPage,
UsersPage,
ReposPage,
OrganisationsPage,
UserDetailsPage,
],
Run Code Online (Sandbox Code Playgroud)
Login.module.ts
import { NgModule } from '@angular/core';
import { IonicPageModule,IonicPage } from 'ionic-angular';
import { LoginPage } from './login';
//import { IonicPage } from 'ionic-angular';
@IonicPage()
@NgModule({
declarations: [
LoginPage,
],
imports: [
IonicPageModule.forChild(LoginPage),
],
entryComponents: [
LoginPage
],
exports: [
LoginPage
]
})
export class LoginPageModule {} …Run Code Online (Sandbox Code Playgroud) 我有一个登录页面和一个主页.我使用本机存储来设置项目,该项目将检查用户是否已登录(Facebook或Google身份验证).如果该项具有值(此检查发生在app.componenet.ts中),则会直接导航到主页.一旦用户登录并且如果恰好最小化应用程序并且在一段时间之后.当用户再次打开应用程序时,在加载几秒后,我会看到登录屏幕(用户已经登录时不应该看到)1秒钟,然后导航到主页.
这是我的app.component.ts
import { Component, ViewChild } from '@angular/core';
import { Platform, Nav, AlertController } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import { LoginPage } from '../pages/login/login';
import { NativeStorage } from '@ionic-native/native-storage';
import { TabsPage } from '../pages/tabs/tabs';
import { Facebook } from 'ionic-native';
import { GooglePlus } from '@ionic-native/google-plus';
@Component({
templateUrl: 'app.html',
})
export class MyApp {
@ViewChild(Nav) nav: Nav;
rootPage: any = LoginPage;
constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen, …Run Code Online (Sandbox Code Playgroud) 我定义了这个翻译:
"...已在{{param3 | date:'mediumDate'}},{{param3 | date:'shortTime'}}" 创建{{param1}}({{param2}})
param1和param2被替换但是param3不是({{param3 | date:'mediumDate'}},{{param3 | date:'shortTime'}}被打印出来... ...我怎样才能在翻译中使用日期管道?
我收到推送通知消息,一旦收到消息,我想重定向到另一个页面或显示另一个页面而不是主页.
NavController 在这里不起作用,所以我想知道会是什么?
export class MyApp{
rootPage:any = HomePage;
constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen, public push: Push) {
platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.
statusBar.styleDefault();
splashScreen.hide();
});
this.push.rx.notification()
.subscribe((msg) => {
alert(msg.title + ': ' + msg.text);
// I want to redirect to another page with msg object instead of HomePage
});
}
}
Run Code Online (Sandbox Code Playgroud)
因为在MyApp {}下的app.component.ts中,当我声明constructor(public …
我有一个输入字段,用户可以输入他的地址并获得自动建议:
<ion-label color="primary" stacked>Adresse:</ion-label>
<ion-input type="text" ng-model="autocomplete.query" ng-change="updateSearch()"></ion-input>
Run Code Online (Sandbox Code Playgroud)
我的班级有一个更新方法,我想做点什么,但不幸的是他没有进入它.
updateSearch()
{
console.log('aaa');
if (this.autocomplete.query == '') {
this.autocompleteItems = [];
return;
}
}
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
我想每1秒运行一次功能.搜索后,我发现setInterval但它对我不起作用.
setInterval(function(){
this.myfuntion();
}, 1000);
Run Code Online (Sandbox Code Playgroud)
我也试过,this.myfuntion但它也不起作用.
我想将图像设置为我的Ionic 2应用程序的每个页面的括号.
我知道如何在一个页面的HTML或CSS中做到这一点(我可以在所有页面中完成).
我知道如何设置整个应用程序的背景颜色 theme\variables.scss
$background-color: map-get($map: $colors, $key: primary);
Run Code Online (Sandbox Code Playgroud)
(例如)
但它似乎也在做同样的事情
$background-image: url('assets/images/background-image.jpg');
Run Code Online (Sandbox Code Playgroud)
不起作用.即使一页的css中完全相同的行也能正常工作.
.class-name-here{
background-image: url('assets/images/background-image.jpg');
}
Run Code Online (Sandbox Code Playgroud)
是否可以将图像设置为Ionic 2/Ionic 3中整个应用程序的默认背景?
我正在检查一些本地存储信息,根据我得到的信息,我想加载适当的页面.
所以在我,app.component.ts我有以下.
export class MyApp {
rootPage: string;
constructor(){
if(dataFound)
this.rootPage="HomePage"
else
this.rootPage="OtherPage"
}
}
Run Code Online (Sandbox Code Playgroud)
有没有办法在设置时传递数据this.rootPage.
请记住,这是应用的初始加载.如果在应用程序加载后发生这种情况,我可以这样做this.navCtrl.setRoot(),这将允许我传递参数和页面.
任何帮助表示赞赏.
谢谢
ionic3 ×10
angular ×9
ionic2 ×8
typescript ×5
angularjs ×1
background ×1
css ×1
firebase ×1
javascript ×1