Reusing schema definitions in angular-schema-form via the $ref identifier is not officially supported. Here's how to get them to work anyway
You have a set of values, which the user can enter in multiple forms throughout your application.
For example you have a form in which the user can enter data about her city of birth as well as current city of residence.
This is an unnecessary repetition. It is better maintainable if you write a separate schema for your CityModel like so:
and include it in your PersonalDataModel.schema via the definitions
property and provide a reference to it in both your cityOfBirth and cityOfResidence declaration.
Unfortunately, resolving json-schema $refs is not supported by angular-json-forms out of the box
You have to include the json-refs library into your project.
If you’re using bower this can be accomplished by calling
and including the json-refs file into your build.
In the controller where you want to use your schema, you have to call
Now you have the city schema in both PersonalDataModel.cityOfBirth and PersonalDataModel.cityOfResidence.