gund / ng-dynamic-component

Dynamic components with full life-cycle support for inputs and outputs for Angular
https://malkevich-alex.gitbook.io/ng-dynamic-component/
MIT License
561 stars 65 forks source link

Calling function 'DynamicModule', function calls are not supported #87

Closed Romul6 closed 6 years ago

Romul6 commented 7 years ago

Hi everyone!

i'm trying to use ng-dynamic-component in my app, I follow the instructions in github, to use it and that error show

ERROR in Error: Error encountered resolving symbol values statically. Calling function 'DynamicModule', function calls are not supported. Consider replacing the function or lambda wi th a reference to an exported function, resolving symbol GridModule in C:/src/MyApp/src/app/pages/grid/grid.module.ts, resolving symbol GridModule in C:/src/MyApp/src/app/pages/grid/grid.module.ts at syntaxError (C:\src\MyApp\node_modules\@angular\compiler\bundles\compiler.umd.js:1729:34) at simplifyInContext (C:\src\MyApp\node_modules\@angular\compiler\bundles\compiler.umd.js:24979:23) at StaticReflector.simplify (C:\src\MyApp\node_modules\@angular\compiler\bundles\compiler.umd.js:24991:13) at StaticReflector.annotations (C:\src\MyApp\node_modules\@angular\compiler\bundles\compiler.umd.js:24418:41) at _getNgModuleMetadata (C:\src\MyApp\node_modules\@angular\compiler-cli\src\ngtools_impl.js:138:31) at _extractLazyRoutesFromStaticModule (C:\src\MyApp\node_modules\@angular\compiler-cli\src\ngtools_impl.js:109:26) at includeLazyRouteAndSubRoutes (C:\src\MyApp\node_modules\@angular\compiler-cli\src\ngtools_impl.js:66:25) at Array.reduce (native) at includeLazyRouteAndSubRoutes (C:\src\MyApp\node_modules\@angular\compiler-cli\src\ngtools_impl.js:67:26) at Array.reduce (native) at Object.listLazyRoutesOfModule (C:\src\MyApp\node_modules\@angular\compiler-cli\src\ngtools_impl.js:54:36) at Function.NgTools_InternalApi_NG_2.listLazyRoutes (C:\src\MyApp\node_modules\@angular\compiler-cli\src\ngtools_api.js:91:39) at AotPlugin._getLazyRoutesFromNgtools (C:\src\MyApp\node_modules\@ngtools\webpack\src\plugin.js:207:44) at _donePromise.Promise.resolve.then.then.then.then.then (C:\src\MyApp\node_modules\@ngtools\webpack\src\plugin.js:443:24) at <anonymous> at process._tickCallback (internal/process/next_tick.js:169:7)

Angular Versions:

@angular/cli: 1.4.3 node: 8.1.2 os: win32 x64 @angular/animations: 4.4.6 @angular/cdk: 2.0.0-beta.11 @angular/common: 4.4.6 @angular/compiler: 4.4.6 @angular/core: 4.4.6 @angular/forms: 4.4.6 @angular/http: 4.4.6 @angular/material: 2.0.0-beta.11 @angular/platform-browser: 4.4.6 @angular/platform-browser-dynamic: 4.4.6 @angular/router: 4.4.6 @angular/cli: 1.4.3 @angular/compiler-cli: 4.4.6 typescript: 2.6.1

ng-dynamic-component version use : ^1.0.0

Any ideas???

gund commented 7 years ago

Maybe you have wrong import statement?
Can you please post your module where you are importing this module?

Romul6 commented 7 years ago

Yep! sorry.

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { GridComponent } from 'app/pages/grid/grid.component'
import { SharedModule } from 'app/shared/shared.module';
import { RouterModule } from '@angular/router';
import { NgUploaderModule } from 'ngx-uploader';
import { SecurePipeModule } from 'app/services/pipes/secure-pipe/secure-pipe.module';
//grid
import { NgGridModule } from 'angular2-grid';
import { GridsterModule } from 'angular-gridster2';
//Dynamic
import { DynamicModule } from 'ng-dynamic-component';
import { CaptionDataComponentComponent } from 'app/dashboardComponents/caption-data-component/caption-data-component.component';
import { DigitalDataComponentComponent } from 'app/dashboardComponents/digital-data-component/digital-data-component.component';
import { CaptionComponentComponent } from 'app/dashboardComponents/caption-component/caption-component.component';

const GRID_ROUTE = [
  { path: '', component: GridComponent },
];

@NgModule({
  imports: [
    CommonModule,
    SharedModule,
    RouterModule.forChild(GRID_ROUTE),
    NgUploaderModule,
    SecurePipeModule,
    NgGridModule,
    GridsterModule,
  DynamicModule.withComponents([CaptionComponentComponent,CaptionDataComponentComponen,DigitalDataComponentComponent])
  ],
  declarations: [
    GridComponent,
  ]
})
export class GridModule { }
gund commented 7 years ago

Thanks for posting. That looks fine to me...

Have you declared your dynamic components somewhere?

Because Dynamic module will not do that, it just makes sure angular will produce factories for them.

Romul6 commented 7 years ago

Hi!

yes I try declare inside GridModule like:

@NgModule({
  imports: [
    CommonModule,
    SharedModule,
    RouterModule.forChild(GRID_ROUTE),
    NgUploaderModule,
    SecurePipeModule,
    NgGridModule,
    GridsterModule,
    DynamicModule.withComponents([CaptionComponentComponent,DigitalDataComponentComponent,CaptionDataComponentComponent])
  ],
  declarations: [
    GridComponent,
    CaptionDataComponentComponent,
    CaptionComponentComponent,
    DigitalDataComponentComponent,
  ],
  providers: []
})
export class GridModule { }

and show the same errror.

Thanks!

gund commented 7 years ago

Ah I guess the issue is in TS version you are using. Try to set it to ~2.3.0 and then compile again.

Romul6 commented 7 years ago

hi! thanks for the answer, but this error keeping showing. Is possible that error shows for the angular-cli version? i say for the trace route . Thats my stat right now.

@angular/cli: 1.4.3
node: 8.1.2
os: win32 x64
@angular/animations: 4.4.6
@angular/cdk: 2.0.0-beta.11
@angular/common: 4.4.6
@angular/compiler: 4.4.6
@angular/core: 4.4.6
@angular/forms: 4.4.6
@angular/http: 4.4.6
@angular/material: 2.0.0-beta.11
@angular/platform-browser: 4.4.6
@angular/platform-browser-dynamic: 4.4.6
@angular/router: 4.4.6
@angular/cli: 1.4.3
@angular/compiler-cli: 4.4.6
typescript: 2.3.0

Thanks!

gund commented 7 years ago

Quite possible. Since you are using angular v4 try to downgrade ng cli to the latest version that was for angular 4 and see what happens.

gund commented 6 years ago

Closing due to inactivity.

pixel-perfectionist commented 6 years ago

I have the same issue, that's what I have right now: "@angular/cli": "1.4.4", "@angular/compiler-cli": "^4.2.4", "@angular/language-service": "^4.2.4", "@types/jasmine": "~2.5.53", "@types/jasminewd2": "~2.0.2", "@types/node": "~6.0.60", "codelyzer": "~3.2.0", "jasmine-core": "~2.6.2", "jasmine-spec-reporter": "~4.1.0", "karma": "~1.7.0", "karma-chrome-launcher": "~2.1.1", "karma-cli": "~1.0.1", "karma-coverage-istanbul-reporter": "^1.2.1", "karma-jasmine": "~1.1.0", "karma-jasmine-html-reporter": "^0.2.2", "protractor": "~5.1.2", "ts-node": "~3.2.0", "tslint": "~5.7.0", "typescript": "^2.6.1"

pixel-perfectionist commented 6 years ago

"ng-dynamic-component": "^2.1.4",

Each time when I'm compiling I get t er same error...