Angular 所有角度2';当我通过哈希路由器打开页面时,s的模板语法被破坏

Angular 所有角度2';当我通过哈希路由器打开页面时,s的模板语法被破坏,angular,angular-routing,angular-template,Angular,Angular Routing,Angular Template,我有一个散列路由器,从我的主页路由刚刚好。当一个新页面打开时,所有的模板语法都被破坏了。这就是所有的数据绑定、NGFOR,甚至[routerLink]。因此,页面打开时没有角度逻辑,但是如果我在这些散列页面上刷新浏览器,它们就可以正常工作 app引导文件 import { enableProdMode } from '@angular/core'; import { disableDeprecatedForms, provideForms } from '@angular/forms'; imp

我有一个散列路由器,从我的主页路由刚刚好。当一个新页面打开时,所有的模板语法都被破坏了。这就是所有的数据绑定、NGFOR,甚至[routerLink]。因此,页面打开时没有角度逻辑,但是如果我在这些散列页面上刷新浏览器,它们就可以正常工作

app引导文件

import { enableProdMode } from '@angular/core';
import { disableDeprecatedForms, provideForms } from '@angular/forms';
import { HTTP_PROVIDERS } from '@angular/http';
import { bootstrap } from '@angular/platform-browser-dynamic';
import { LocationStrategy, HashLocationStrategy } from '@angular/common';
import { APP_ROUTER_PROVIDERS }  from './path-to-the-router-file';
import { ServerGetService } from './path-to-a-service';
import { AppComponent } from './app/app.component';

// depending on the env mode, enable prod mode or add debugging modules
if (process.env.ENV === 'build') {
  enableProdMode();
}

bootstrap(AppComponent, [
  HTTP_PROVIDERS,
  APP_ROUTER_PROVIDERS,
  {
    provide: LocationStrategy,
    useClass: HashLocationStrategy
  },
  ServerGetService,
  disableDeprecatedForms(),
  provideForms()
]).catch((err: any) => console.error(err));
import {provideRouter, RouterConfig} from '@angular/router';
import {SecondPopUpComponent} from './path-to-the-file';
import {firstPopUpComponent} from './path-to-the-file';
import {Component} from '@angular/core';

@Component({
  selector: 'mx-empty',
  template: '<div></div>'
})
class EmptyComponent {}

export const routes: RouterConfig =
  <RouterConfig>[
    {
      path: 'second-popup',
      component: SecondPopUpComponent
    }, {
      path: 'first-popup',
      component: FirstPopUpComponent
    }, {
      path: '',
      component: EmptyComponent
    }
  ];

export const APP_ROUTER_PROVIDERS = [
  provideRouter(routes)
];
路由文件

import { enableProdMode } from '@angular/core';
import { disableDeprecatedForms, provideForms } from '@angular/forms';
import { HTTP_PROVIDERS } from '@angular/http';
import { bootstrap } from '@angular/platform-browser-dynamic';
import { LocationStrategy, HashLocationStrategy } from '@angular/common';
import { APP_ROUTER_PROVIDERS }  from './path-to-the-router-file';
import { ServerGetService } from './path-to-a-service';
import { AppComponent } from './app/app.component';

// depending on the env mode, enable prod mode or add debugging modules
if (process.env.ENV === 'build') {
  enableProdMode();
}

bootstrap(AppComponent, [
  HTTP_PROVIDERS,
  APP_ROUTER_PROVIDERS,
  {
    provide: LocationStrategy,
    useClass: HashLocationStrategy
  },
  ServerGetService,
  disableDeprecatedForms(),
  provideForms()
]).catch((err: any) => console.error(err));
import {provideRouter, RouterConfig} from '@angular/router';
import {SecondPopUpComponent} from './path-to-the-file';
import {firstPopUpComponent} from './path-to-the-file';
import {Component} from '@angular/core';

@Component({
  selector: 'mx-empty',
  template: '<div></div>'
})
class EmptyComponent {}

export const routes: RouterConfig =
  <RouterConfig>[
    {
      path: 'second-popup',
      component: SecondPopUpComponent
    }, {
      path: 'first-popup',
      component: FirstPopUpComponent
    }, {
      path: '',
      component: EmptyComponent
    }
  ];

export const APP_ROUTER_PROVIDERS = [
  provideRouter(routes)
];
popup.page.html

<div class="form-popup">
  <div class="form-popup__overlay"></div>
  <div class="form-popup__content">
    <form #dataForm="ngForm" (ngSubmit)="onSubmit()">
      <fieldset>
        <legend>Properties</legend>
        <table>
          <thead>
          <tr>
            <th>first column</th>
            <th>secondcolumn</th>
            <th>third column</th>
          </tr>
          </thead>
          <tbody>
          <tr *ngFor='let data of localData'>
            <td>{{data.attr1}}</td>
            <td>{{data.attr2}}</td>
            <td>
              <label>
                <input type='checkbox' [(ngModel)]='localData.isSet' [ngModelOptions]="{standalone: true}">
              </label>
            </td>
          </tr>
          </tbody>
        </table>
        <div>
          <button type="submit">OK</button>
          <a [routerLink]="['']" >Cancel</a>
        </div>
      </fieldset>
    </form>
  </div>
</div>

性质
第一列
第二列
第三纵队
{{data.attr1}
{{data.attr2}
好啊
取消
弹出文件中唯一有效的是onSubmit(),它甚至会路由,但其余的绑定不会,当我单击
取消
时,应该执行
[routerLink]=“[”””
,我得到了这个错误
VM55939:84原始异常:TypeError:无法读取未定义的属性“startsWith”


有什么办法吗?

问题是团队中有人在polyfills中添加了这一行:
require('zone.js/dist/zone')


我仍然不知道它是做什么的,为什么会破坏应用程序,但当我删除它时,一切都正常了

什么是哈希路由器?
useClass:HashLocationStrategy
它只是一个路由器,我只是想它可能与此有关