【发布时间】:2017-11-27 23:51:59
【问题描述】:
我收到推送通知消息,收到消息后,我想重定向到另一个页面或显示另一个页面而不是主页。
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
});
}
}
因为在 MyApp{} 下的 app.component.ts 中,当我声明 constructor(public navCtrl:nacNavController) 时出现以下错误:
Error: Uncaught (in promise): Error: No provider for NavController!
Error: No provider for NavController!
at injectionError (main.js:1509)
at noProviderError (main.js:1547)
at ReflectiveInjector_._throwOrNull (main.js:3048)
at ReflectiveInjector_._getByKeyDefault (main.js:3087)
at ReflectiveInjector_._getByKey (main.js:3019)
at ReflectiveInjector_.get (main.js:2888)
at AppModuleInjector.NgModuleInjector.get (main.js:3835)
at resolveDep (main.js:11202)
at createClass (main.js:11071)
at createDirectiveInstance (main.js:10899)
at injectionError (main.js:1509)
at noProviderError (main.js:1547)
at ReflectiveInjector_._throwOrNull (main.js:3048)
at ReflectiveInjector_._getByKeyDefault (main.js:3087)
at ReflectiveInjector_._getByKey (main.js:3019)
at ReflectiveInjector_.get (main.js:2888)
at AppModuleInjector.NgModuleInjector.get (main.js:3835)
at resolveDep (main.js:11202)
at createClass (main.js:11071)
at createDirectiveInstance (main.js:10899)
at c (polyfills.js:3)
at polyfills.js:3
at polyfills.js:3
at t.invoke (polyfills.js:3)
at r.run (polyfills.js:3)
at polyfills.js:3
at t.invokeTask (polyfills.js:3)
at r.runTask (polyfills.js:3)
at o (polyfills.js:3)
at <anonymous>
【问题讨论】:
-
你说的 NavController 在这里不起作用是什么意思?
-
我的意思是在 app.component.ts 中,当我使用
NavController时出现错误 Error: Uncaught (in promise): Error: No provider for NavController!
标签: angular typescript ionic2 ionic3