jaumard / ngx-dashboard

Dashboard library for angular 4 and more
https://jaumard.github.io/ngx-dashboard/demo/demoDist/index.html
MIT License
71 stars 31 forks source link

Not working in angular 2 #10

Closed kirtiesl closed 7 years ago

kirtiesl commented 7 years ago

I have integrated ngx-dashboard in angular 2. Getting following error:

EXCEPTION: Uncaught (in promise): Error: Can't resolve all parameters for DashboardComponent: ([object Object], [object Object], ?).

Please suggest.

jaumard commented 7 years ago

Hum can you share a little project to reproduce the problem please ? Like this I an take a look more quickly. I don't use it anymore on angular 2 as I migrate to 4 so maybe there a compatibility problem.

kirtiesl commented 7 years ago

Here are my file -

1)dashboard-widgets.module.ts

import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; import { CommonModule } from '@angular/common'; import { MaterialModule } from '@angular/material'; import { DashboardWidgetsComponent } from './dashboard-widgets.component'; import { DashboardWidgetsRoutes } from './dashboard-widgets.routing'; import {Ng2DashboardModule} from 'ngx-dashboard';

@NgModule({ imports: [CommonModule, RouterModule.forChild(DashboardWidgetsRoutes), MaterialModule,Ng2DashboardModule], declarations: [DashboardWidgetsComponent], providers: [] }) export class DashboardWidgetsModule {}

2)dashboard-widgets.component.ts

import {Component, Renderer, ElementRef, forwardRef} from "@angular/core"; import {WidgetComponent} from "ngx-dashboard"; @Component({ selector: 'app-dashboard-widgets', templateUrl: './dashboard-widgets.component.html', providers: [{provide: WidgetComponent, useExisting: forwardRef(() => DashboardWidgetsComponent) }] }) export class DashboardWidgetsComponent extends WidgetComponent{ constructor(ngEl: ElementRef, renderer: Renderer) { super(ngEl, renderer); } }

3)dashboard-widgets.component.html

<widget [size]="[2, 1]">

Large widget [2, 1] handle only on this text
<div>All other stuff...</div>

jaumard commented 7 years ago

WidgetComponent now use Renderer2 not Renderer, try to change your DashboardWidgetsComponent to use Renderer2, maybe it's just that

nadir35 commented 7 years ago

Also experienced same problem. Changing Renderer didn't help. Changed to Angular4.

jaumard commented 7 years ago

@nadir35 same if you have a small project to share it will be helpful :)

jaumard commented 7 years ago

I just notice that Renderer2 is not part of angular2, only in angular4 so no way it will work unfortunately :(

jaumard commented 7 years ago

I prefer not get back to the now deprecated Renderer class so I prefer leave angular 2 behind, sorry for that please try to upgrade to angular 4