Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to import/use library on clean Angular CLI project #57

Closed
1 of 5 tasks
edoardoo opened this issue Dec 26, 2018 · 3 comments
Closed
1 of 5 tasks

Unable to import/use library on clean Angular CLI project #57

edoardoo opened this issue Dec 26, 2018 · 3 comments

Comments

@edoardoo
Copy link

Describe the bug
which template:

  • MaterialDesignFrameworkModule — Material Design
  • Bootstrap3FrameworkModule — Bootstrap 3
  • Bootstrap4FrameworkModule — Bootstrap 4
  • NoFrameworkModule — plain HTML
  • Other (please specify below)

Tried using the library both on the project I'm working on and on a brand new clean project created using Angular CLI. Followed the instructions both on README.md and the example project, both lead to errors.

To Reproduce
Steps to reproduce the behavior:

  1. Create new project with Angular CLI: ng new testAngular
  2. Install dependencies, modifying package.json and running rm -rf node_modules/ && npm i:
{
  "name": "test-angular",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~7.0.0",
    "@angular/cdk": "^7.0.0",
    "@angular/common": "~7.0.0",
    "@angular/compiler": "~7.0.0",
    "@angular/core": "~7.0.0",
    "@angular/flex-layout": "^7.0.0-beta.22",
    "@angular/forms": "~7.0.0",
    "@angular/http": "~7.0.0",
    "@angular/material": "^7.2.0",
    "@angular/platform-browser": "~7.0.0",
    "@angular/platform-browser-dynamic": "~7.0.0",
    "@angular/router": "~7.0.0",
    "angular6-json-schema-form": "^7.0.1",
    "core-js": "^2.5.4",
    "rxjs": "~6.3.3",
    "zone.js": "~0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.10.0",
    "@angular/cli": "~7.0.5",
    "@angular/compiler-cli": "~7.0.0",
    "@angular/language-service": "~7.0.0",
    "@types/node": "~8.9.4",
    "@types/jasmine": "~2.8.8",
    "@types/jasminewd2": "~2.0.3",
    "codelyzer": "~4.5.0",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~3.0.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~1.1.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.4.0",
    "ts-node": "~7.0.0",
    "tslint": "~5.11.0",
    "typescript": "~3.1.6"
  }
}

  1. Edit app.module.ts :
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import {
  MatButtonModule,
  MatCardModule,
  MatCheckboxModule,
  MatSidenavModule,
  MatToolbarModule,
  MatIconModule,
  MatListModule,
  MatInputModule,
  MatMenuModule,
  MatDialogModule,
  MatSnackBarModule,
  MatTabsModule,
  MatTableModule,
  MatSortModule,
  MatSelectModule
} from '@angular/material';
import { JsonSchemaFormModule, NoFrameworkModule } from 'angular6-json-schema-form';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    MatButtonModule,
    MatCardModule,
    MatCheckboxModule,
    MatSidenavModule,
    MatToolbarModule,
    MatIconModule,
    MatListModule,
    MatInputModule,
    MatMenuModule,
    MatDialogModule,
    MatSnackBarModule,
    MatTabsModule,
    MatTableModule,
    MatSortModule,
    MatSelectModule,
    NoFrameworkModule,
    NoFrameworkModule, JsonSchemaFormModule.forRoot(NoFrameworkModule)
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

  1. Add form tag to html, and scheme data to ts:
<json-schema-form
  loadExternalAssets="true"
  [schema]="yourJsonSchema"
  framework="no-framework"
  (onSubmit)="yourOnSubmitFn($event)">
</json-schema-form>

the yourJsonSchema is a random form taken from the example category
5. ng serve

Expected behavior
The app compile and shows a form.

Screenshots
No relevant screenshot saved.

Desktop (please complete the following information):

  • OS: OsX
  • Browser Firefox
  • Version 65.0b5 (64-bit)

Log output covering before error and any error statements

ERROR in src/app/app.module.ts(23,10): error TS2305: Module '"/Users/edo/Gits/testAngular/node_modules/angular6-json-schema-form/angular6-json-schema-form"' has no exported member 'JsonSchemaFormModule'.

Additional context
Importing the library as specified in the README.md didn't work either.

@sverdlov
Copy link

sverdlov commented Mar 4, 2019

Duplicate of #88

@hamzahamidi
Copy link
Owner

Hi @edoardoo . That's not how you import angular6-json-schema-form.
You need to follow the following steps as mentioned in the docs
NB: note that you shouldn't import JsonSchemaFormModule :

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { Bootstrap4FrameworkModule } from 'angular6-json-schema-form';

import { AppComponent } from './app.component';

@NgModule({
  declarations: [ AppComponent ],
  imports: [
    BrowserModule
    Bootstrap4FrameworkModule
  ],
  providers: [],
  bootstrap: [ AppComponent ]
})
export class AppModule { }

And you use the component like the following:

<json-schema-form
loadExternalAssets="true"
[schema]="schema"
framework="bootstrap-4"
(onSubmit)="submit($event)">
</json-schema-form>

If you still face the same issue, can you make a repository to reproduce this issue?

@bronsonholden
Copy link

This issue may still need to be open. Even if you correctly only import NoFrameworkModule, you get an error saying json-schema-form is not a known element.

If you create a new app, install dependencies, and set up with NoFrameworkModule, this occurs.

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { NoFrameworkModule } from 'angular6-json-schema-form'
import { AppComponent } from './app.component';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    NoFrameworkModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

My current workaround is to also import one of the other modules (e.g. MaterialDesignFrameworkModule).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants