Find answers to frequently asked questions about ngx-schema-to-code library, including setup, customization, and troubleshooting tips for Angular developers.
Assuming that you have already install dependecies like angular material, material moment adapter(compatible version with your angular version) and json server. Your application must have created using Angular 20 or above version.
Add ngx-schema-to-code to the project.
ng add ngx-schema-to-codeCreate a json schema file as per documentation and save in root folder of the project.
Generate CURD code with all components, services, navigation and shared components & services.
ng g ngx-schema-to-code:curd <json-file-name>Start the json server if you install locally
npm run apiIf you have install json-server globally then use following command
json-server db.json --watchNow run the application and test CURD functionality
ng serve --openNo, it has used all new stable features like standalone components, signal apis, etc.. that supports Angular 20 and above versions.
To fill the select control's options with api response use following metadata, do not use options or optionValues sub-property
catetogy: {
"dataType": "string" //string or number
"inputType": "select"
"source": "http://localhost:3000/category" //any working url
"descField": "name"
"valField": "code"
"parentObject": "data" //only if expected option data not available at response's root level, change 'data' with actual parent property.
}
To fill the select control's options with string array define property like below.
"department": {
"dataType": "string"
"inputType": "select"
"optionValues": ["Account", "Human Resource", "Management", "Sales"]
}
To add checkbox-list control define property as below.
"hobbies": {
"dataType": "array"
"inputType": "checkbox"
"options": [
{
"description": "Music"
"value": "music"
},
{
"description": "Adventure"
"value": "adventure"
},
{
"description": "Singing"
"value": "singing"
}
]
}
Define the group of controls as follow:
"address": {
"dataType": "group"
"inputType": "group"
"properties": {
"area": {
"dataType": "string"
"inputType": "text"
},
"city": {
"dataType": "string"
"inputType": "text"
},
"state": {
"dataType": "string"
"inputType": "select"
"optionValues": ["Delhi", "Mumbai", "Chennai", "Kolkatta", "Banglore", "Pune"]
},
"pinCode": {
"dataType": "number"
"inputType": "number"
"validation": {
"pattern": "^[1-9]{1}[0-9]{5}$"
}
}
}
}
Yes, you can add "required" validation to array, that means at least one item is required.
When you define inputType as "email", system will add following pattern validation by default, you need not add explicitly.
'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,4}$'