Coder Social home page Coder Social logo

ng2-admin's Introduction

ng2-admin

angular2,ng2-bootstrap,ng2-smart-table

在使用ng2-admin的时候遇到的问题

1. ng2-bootstarp中的modal弹出出错

error_handler.js:53 Error: ApplicationRef instance not found
    at ComponentsHelper.getRootViewContainerRef (components-helper.service.js:50)
    at ComponentsHelper.appendNextToRoot (components-helper.service.js:94)
    at ModalDirective.showBackdrop (modal.component.js:191)
    at ModalDirective.show (modal.component.js:108)
    at AppComponent.ngAfterViewInit (app.component.ts:22)
    at _View_AppComponent_Host0.detectChangesInternal (host.ngfactory.js:36)
    at _View_AppComponent_Host0.AppView.detectChanges (view.js:219)
    at _View_AppComponent_Host0.DebugAppView.detectChanges (view.js:324)
    at ViewRef_.detectChanges (view_ref.js:130)
    at application_ref.js:437

解决方法:

1. 在app.module里面
import { ComponentsHelper } from 'ng2-bootstrap';
providers: [{
  provide: ComponentsHelper, useClass: ComponentsHelper
}]
2. 在app.components里面
import { ViewContainerRef } from '@angular/core';
import { ComponentsHelper } from 'ng2-bootstrap';

export class App {
    viewContainerRef: any;
    public constructor( _comhelp: ComponentsHelper, _vcr: ViewContainerRef) {
    this.viewContainerRef = _vcr;
    _comhelp.setRootViewContainerRef(_vcr);
    }
}
3. 在app.components最后添加
ComponentsHelper.prototype.getRootViewContainerRef = function () {
    if (this.root) {
        return this.root;
    }
    let comps = this.applicationRef.components;
    if (!comps.length) {
        throw new Error(`ApplicationRef instance not found`);
    }
    try {
        let rootComponent = this.applicationRef._rootComponents[0];
        this.root = rootComponent._component.viewContainerRef || rootComponent._hostElement.vcRef;
        return this.root;
    }
    catch (e) {
        throw new Error(`ApplicationRef instance not found`);
    }
};

ng2-admin's People

Contributors

freeser avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.