繁体   English   中英

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

[英]Angular 4 “Uncaught Error: Zone already loaded.” using modal dialog bootstrap

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

这是我的脚本:master-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>

并有如下图所示的错误

在此输入图像描述

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

我在角度应用程序中遇到了相同的modal-popup问题,我找到了一个解决方案:你需要将代码更改为master-golongan.component.html文件:

不要使用'routerLink'而不是'href'进行数据切换模式,只需更改'href'而不是'routerLink'并检查其工作情况:

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

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

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM