目前无法看到使用这样的导航保护点,因为我们不知道要导航到的目标页面(活动页面信息可以从navController getActive()方法获得).通常情况下,我们会使用提醒来询问"你真的想离开这个页面吗?" 为了响应一个菜单选项被选中,例如OK,据我所知,我们不知道"setRoot"哪个页面作为目标页面,因为ionViewCanLeave处理程序没有参数,如toPage/enteringPage.
有没有人设法做到这一点还是宁愿从ionic2目标页面信息中的导航对象中找到?
这里有一些设置上下文的代码:
ionViewCanLeave(): boolean { // no parameters on offer :-(
let result: boolean = false;
let alert: Alert = this._alertCtrl.create({
title: 'Are you sure you want to leave..?',
message: 'Your changes will be lost if you do?',
buttons: [
{
text: 'Cancel',
role: 'cancel',
handler: () => {
let dismiss: boolean = true;
return dismiss;
}
},
{
text: 'OK',
handler: () => {
let dismiss: boolean = false;
let alertPop = alert.dismiss();
alertPop
.then(() => …
Run Code Online (Sandbox Code Playgroud)所以我正在使用来自 swiip 的一个名为 generator-gulp-angular 的 yeoman 项目 - 只需执行“npm search gulp-angular”,你就会看到它。
开箱即用的客户端从 127.0.0.1:3000 运行,我希望对 127.0.0.1:8080 上的(python)服务进行 $http 调用。它使用浏览器同步进行实时重新加载和代理中间件来进行从客户端到服务器的代理调用。代理中间件默认是禁用的,所以诀窍是启用它并成功地向服务器发出请求并从服务器接收响应。到目前为止,我还没有能够成功启用它:-(
更新:我按照“给自己一个简单的例子”的座右铭重新创建了 yeoman 项目,以便专注于访问控制问题,并且我让它或多或少地开箱即用,而不必求助于修改服务器逻辑以允许跨源请求。令人高兴的是,它就像说明中描述的一样简单。这是扩展 gulp 中间件以执行代理的代理文件,或者更确切地说是从客户端到服务器的映射:
/*jshint unused:false */
/***************
This file proxy.js allows you to configure a proxy system plugged into BrowserSync
in order to redirect backend requests while still serving and watching
files from the web project
IMPORTANT: The proxy is disabled by default.
If you want to enable it, watch at the configuration options and finally
change the `module.exports` at …
Run Code Online (Sandbox Code Playgroud)