Typescript Router.Parent.Navigate()出现问题

Typescript Router.Parent.Navigate()出现问题,typescript,angular,Typescript,Angular,我在Angular 2中遇到了路由器.parent.navigate的问题。 我不知道这是Angular的问题还是我的代码有问题。 当我有父组件App.ts时,路由和承载所有视图的内容配置 ///<reference path="../../node_modules/angular2/angular2.d.ts"/> ///<reference path="../../node_modules/angular2/router.d.ts"/> ///<referen

我在Angular 2中遇到了路由器.parent.navigate的问题。 我不知道这是Angular的问题还是我的代码有问题。
当我有父组件
App.ts
时,路由和承载所有视图的内容配置

///<reference path="../../node_modules/angular2/angular2.d.ts"/>
///<reference path="../../node_modules/angular2/router.d.ts"/>
///<reference path="./BusinessNameLookup/BusinessNameLookup.ts"/>
///<reference path="./LookupDetails/LookupDetails.ts"/>
///<reference path="./BusinessNames/BusinessNames.ts"/>
///<reference path="./BusinessWebAddress/BusinessWebAddress.ts"/>
///<reference path="./BusinessCategory/BusinessCategory.ts"/>
///<reference path="./ContactInformations/ContactInformations.ts"/>
///<reference path="./BusinessPurchaseAddress/BusinessPurchaseAddress.ts"/>
///<reference path="./BusinessImages/BusinessImages.ts"/>
///<reference path="./SurveyQuery/SurveyQuery.ts"/>
///<reference path="./ABN/ABN.ts"/>

import {bootstrap, Component, View, bind, Inject} from 'angular2/angular2';
import {
ROUTER_DIRECTIVES,
ROUTER_PROVIDERS,
RouteConfig
, ROUTER_BINDINGS, RouterLink, RouterOutlet, Route,
LocationStrategy, HashLocationStrategy} from 'angular2/router';

/* Importing Application Components */
import { BusinessNameLookup } from './BusinessNameLookup/BusinessNameLookup.ts';
import { ABN } from './ABN/ABN.ts';
import { LookupDetails } from './LookupDetails/LookupDetails.ts';
import { Businessnames } from './BusinessNames/BusinessNames.ts';
import { BusinessWebAddress } from './BusinessWebAddress/BusinessWebAddress.ts';
import { BusinessCategory } from './BusinessCategory/BusinessCategory.ts';
import { ContactInformations } from './ContactInformations/ContactInformations.ts';
import { BusinessPurchaseAddress } from './BusinessPurchaseAddress/BusinessPurchaseAddress.ts';
import { BusinessImages } from './BusinessImages/BusinessImages.ts';
import { SurveyQuery } from './SurveyQuery/SurveyQuery.ts';
/* Importing Application Components */

import { BusinessModel } from './DataModels/BusinessModel.ts';

@Component({
    selector: 'app'
})

@View({
        template: `<router-outlet></router-outlet>`,
        directives: [RouterOutlet, RouterLink, ROUTER_DIRECTIVES]
})

@RouteConfig([
        new Route({ path: '/', component: BusinessNameLookup }),
        new Route({ path: '/ABN', component: ABN, name: 'ABN' }),
        new Route({ path: '/LookupDetails', component: LookupDetails, name: 'LookupDetails' }),
        new Route({ path: '/BusinessNames', component: Businessnames, name: 'BusinessNames' }),
        new Route({ path: '/BusinessWebAddress', component: BusinessWebAddress, name: 'BusinessWebAddress' }),
        new Route({ path: '/BusinessCategory', component: BusinessCategory, name: 'BusinessCategory' }),
        new Route({ path: '/ContactInformations', component: ContactInformations, name: 'ContactInformations' }),
        new Route({ path: '/BusinessPurchaseAddress', component: BusinessPurchaseAddress, name: 'BusinessPurchaseAddress' }),
        new Route({ path: '/BusinessImages', component: BusinessImages, name: 'BusinessImages' }),
        new Route({ path: '/SurveyQuery', component: SurveyQuery, name: 'SurveyQuery' })
])

class AppComponent {
}

bootstrap(AppComponent, [ROUTER_BINDINGS, bind(LocationStrategy).toClass(HashLocationStrategy)]);
///
///
///
///
///
///
///
///
///
///
///
///
从'angular2/angular2'导入{bootstrap,Component,View,bind,Inject};
进口{
路由器指令,
路由器供应商,
线路图
,路由器绑定,路由器链接,路由器输出,路由,
LocationStrategy,HashLocationStrategy}来自“angular2/路由器”;
/*导入应用程序组件*/
从“./BusinessNameLookup/BusinessNameLookup.ts”导入{BusinessNameLookup};
从'/ABN/ABN.ts'导入{ABN};
从“./LookupDetails/LookupDetails.ts”导入{LookupDetails};
从“./Businessnames/Businessnames.ts”导入{Businessnames};
从“./BusinessWebAddress/BusinessWebAddress.ts”导入{BusinessWebAddress};
从“./BusinessCategory/BusinessCategory.ts”导入{BusinessCategory};
从“./ContactInformations/ContactInformations.ts”导入{ContactInformations};
从“./BusinessPurchaseAddress/BusinessPurchaseAddress.ts”导入{BusinessPurchaseAddress};
从“./BusinessImages/BusinessImages.ts”导入{BusinessImages};
从“./SurveyQuery/SurveyQuery.ts”导入{SurveyQuery};
/*导入应用程序组件*/
从“./DataModels/BusinessModel.ts”导入{BusinessModel};
@组成部分({
选择器:“应用程序”
})
@看法({
模板:``,
指令:[RouterOutlet、RouterLink、ROUTER_指令]
})
@线路图([
新路由({path:'/',组件:BusinessNameLookup}),
新路由({path:'/ABN',组件:ABN,名称:'ABN'}),
新路由({path:'/LookupDetails',组件:LookupDetails,名称:'LookupDetails'}),
新路由({path:'/BusinessNames',组件:BusinessNames,名称:'BusinessNames'}),
新路由({path:'/BusinessWebAddress',组件:BusinessWebAddress,名称:'BusinessWebAddress'}),
新路由({path:'/BusinessCategory',组件:BusinessCategory,名称:'BusinessCategory'}),
新路由({path:'/ContactInformations',组件:ContactInformations,名称:'ContactInformations'}),
新路由({path:'/BusinessPurchaseAddress',组件:BusinessPurchaseAddress,名称:'BusinessPurchaseAddress'}),
新路由({path:'/BusinessImages',组件:BusinessImages,名称:'BusinessImages'}),
新路由({路径:'/SurveyQuery',组件:SurveyQuery,名称:'SurveyQuery'})
])
类AppComponent{
}
引导(AppComponent,[ROUTER_BINDINGS,bind(LocationStrategy).toClass(HashLocationStrategy)];
当我写它时,这会将我导航到主页并在
属性中查看它。 不,我一直在放
this.router.parent.navigate(['/ABN'])

这一行我把它变成了按钮调用的函数。 问题开始时,我按下此按钮,我已导航到另一页一段时间,然后再次返回主页,并在URL中显示问号符号
http://localhost:5000/?
,它也会消失。

当处理导航事件的
位于
元素内时,这似乎是一个问题

例如:

//Component function
gotoAnotherRoute() { 
  this._router.navigate(['/another-route']);
}      
此模板将刷新页面并在URL中添加问号符号

<form>
  <input [(ngModel)]="model.name"/>
  <button (click)="gotoAnotherRoute()">Validate</button>
</form>

验证
此模板将正常工作,并按预期进行布线

<form>
  <input [(ngModel)]="model.name"/>
</form>
<button (click)="gotoAnotherRoute()">Validate</button>

验证

导航后只需返回false

//Component function
gotoAnotherRoute() { 
   this._router.navigate(['/another-route']);
   return false;
}    

这是真的臭虫吗?或者这种行为是否有意义。thx.不确定这是否是一个真正的错误,因为HTML表单的标准行为是由“提交”类型的输入提交,或者表单中的第一个按钮(如果不存在提交类型)提交。。。