Template parse errors: Can't bind to 'schema'
nmainardi opened this issue · 3 comments
nmainardi commented
Error: Template parse errors:
Can't bind to 'schema' since it isn't a known property of 'json-schema-form'.
- If 'json-schema-form' is an Angular component and it has 'schema' input, then verify that it is part of this module.
- If 'json-schema-form' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
- To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("
<json-schema-form
loadExternalAssets="true"
[ERROR ->][schema]="yourJsonSchema"
(onSubmit)="yourOnSubmitFn($event)">
"):
But i'm sure the import is correct...
I ran npm install angular2-json-schema-form but it give me an error on flex-layout so I installed the @angular/flex-layout@2.0.0-beta.12
Could be the problem?
Thank you for attention
catull commented
Too little information to help you.
Best guess, you are not declaring or importing it properly.
nmainardi commented
Well, I added
import { FlexLayoutModule } from '@angular/flex-layout';
import { JsonSchemaFormModule, MaterialDesignFrameworkModule } from 'angular2-json-schema-form';
...
imports: [
FormsModule,
ReactiveFormsModule,
FlexLayoutModule,
//other import...
MaterialDesignFrameworkModule,
JsonSchemaFormModule.forRoot(MaterialDesignFrameworkModule)]
in my app.module and directly in app.component.html
<json-schema-form
loadExternalAssets="true"
[schema]="yourJsonSchema"
(onSubmit)="yourOnSubmitFn($event)">
</json-schema-form>
and in my app.component.ts
yourJsonSchema = {
"schema": {
"type": "object",
"title": "Types",
"properties": {
"string": {
"type": "string",
"minLength": 3
},
"integer": {
"type": "integer"
},
"number": {
"type": "number"
},
"boolean": {
"type": "boolean"
}
},
"required": [
"number"
]
}
}
...
yourOnSubmitFn(e){
console.log(e);
}
nmainardi commented
Sorry, I don't really know why but now (also if editor is saying me that
json-schema-form' is not a known element:
1. If 'json-schema-form' is an Angular component, then verify that it is part of this
module.
2. If 'json-schema-form' is a Web Component then add
'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress
this message.
)
it works.
Sorry again and thank you.