角度4“未捕获错误:区域已加载。”使用模态对话框引导程序

时间:2017-11-07 09:41:35

标签: angular

我尝试使用带路由器出口角度4的模态对话框引导程序并获得错误“未捕获错误:区域已加载。”

这是我的脚本: 主golongan.component.ts

import { Component, OnInit } from '@angular/core';
import {Router} from '@angular/router';
import { Title } from '@angular/platform-browser';

@Component({
  selector: 'app-master-golongan',
  templateUrl: './master-golongan.component.html',
  styleUrls: ['./master-golongan.component.css'],
})
export class MasterGolonganComponent implements OnInit {

  golList: any;
  constructor(private title: Title) {
    this.title.setTitle('Daftar Golongan | Inventory Management System');
  }

  ngOnInit() {
  }

}

主golongan.component.html

    <a class="btn btn-success  btn-xs " data-toggle="modal" data-target="#myModal" routerLinkActive="active"
      routerLink="new-edit-golongan">
      <i class="fa fa-plus"></i> Golongan Baru</a>


<div class="modal" id="myModal">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title">Modal title</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <router-outlet></router-outlet>
    </div>
  </div>
</div>

新 - 编辑golongan.component.html

<div class="modal-body">
  <p>Some text in the modal.</p>
</div>
<div class="modal-footer">
  <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>

并且出现如下图所示的错误

enter image description here

如何在模态对话框引导程序中调用router-outlet angular 4?怎么解决呢?

2 个答案:

答案 0 :(得分:0)

遇到同样的问题,https://github.com/angular/angularfire2/issues/1597帮我删除了这个错误。只需从node_modules / angularfire2 / angularfire2.d.ts中评论或删除import 'zone.js';。它对我有用。

问题是,一旦angular有全局定义的zone.js,那么就不必再次导入zone.js了。我正在使用:"angularfire2": "5.0.0-rc.4"

答案 1 :(得分:0)

node_modules/angularfire2/angularfire2.d.ts中,删除以下行 import 'zone.js/dist/zone'; 它会工作:)