Angular 重新加载页面(ngSubmit)不起作用

Angular 重新加载页面(ngSubmit)不起作用,angular,angular6,Angular,Angular6,我有一张表格 <form class="row" style="width: 100%" (ngSubmit)="inf()"> <div class="col-md-12"> <div class="form-group col-md-4"> <label for="cups">Yep</label> <input type="text" cla

我有一张表格

<form class="row" style="width: 100%" (ngSubmit)="inf()">
        <div class="col-md-12">
          <div class="form-group col-md-4">
            <label for="cups">Yep</label>
            <input type="text" class="form-control" id="data" [(ngModel)]="data"
                   [ngModelOptions]="{standalone: true}" value="1">
          </div>
        </div>

        <div class="col-md-6">
          <button type="submit" class="btn btn-primary">Search</button>
        </div>
      </form>
如果我重新加载网站并尝试搜索,则无法工作。(不要在终端上显示“正在工作”)

仅当我使用内部链接routerLink=“”转到此模板时才起作用

路线

const routes: Routes = [
{ path: 'login', component: LoginComponent },
{ path: 'panel', loadChildren: './panel/panel.module#PanelModule' , canActivate: [AuthGuard]},
{ path: '', redirectTo: 'panel', pathMatch: 'full' },
{ path: '**', redirectTo: 'panel' },
];

我敢打赌刷新页面会重置数据。您已绑定到数据
[(ngModel)]=“数据”
。如果您通过路由进入页面,
数据
-对象会像往常一样填充。因此,只有通过路由进入页面时,提交才会起作用。-解决方案:在页面刷新后,找到重新填充
数据的方法。感谢您的评论。我在没有输入的情况下进行了尝试,但什么都没有,如果我重新加载页面,ngSubmit将不起作用。请将组件的typescript代码添加到您的帖子中。不要将其添加为注释。;)补充说,谢谢你的帮助我在我的机器上测试了你的代码。它工作得很好。即使在使用CTRL+R或F5刷新之后。这对你来说似乎是个问题。你使用哪种浏览器?
const routes: Routes = [
{ path: 'login', component: LoginComponent },
{ path: 'panel', loadChildren: './panel/panel.module#PanelModule' , canActivate: [AuthGuard]},
{ path: '', redirectTo: 'panel', pathMatch: 'full' },
{ path: '**', redirectTo: 'panel' },
];