Add-on ngModel builder seems to not work at all
frikinside opened this issue · 3 comments
Hi,
I'm using the 1.0.0-alpha.5 version.
I've been trying to make and add-on and follow the documentation step by step but I'm having a problem with the ngModel builder.
Whenever I try to use any of the three options for sf-field-model the DOM don't change and the ngModel directive isn't getting injected.
Expected behaviour
When I set the attribute sf-field-model on an input control I expect that the ngModel builder takes care of it and inject the ng-model directive with the proper binding.
Sample from the docs:
If I set the template like this:
<div>
<input sf-field-model type="text">
</div>
I expect this result:
<div>
<input sf-field-model ng-model="model['name']" type="text">
</div>
Actual behaviour
Instead of that I'm getting nothing. I'm getting this:
<div>
<input sf-field-model type="text">
</div>
Seems like the builder isn't getting triggered to action.
Please see the plunker bellow to check the addon implementation and a sample of the problem.
Gist/Plunker/Demo
I've prepared a simple plunker to show the issue.
Plunker
In that plunker I set the schema with two properties. A simple string and a string with a format to trigger the addon.
Thanks in advance!
Kindly regards.
@json-schema-form/angular-schema-form-lead
@frikinside there's a newer way to work with add-ons, take a look at https://github.com/json-schema-form/angular-schema-form/blob/development/examples/add-on/calculate.js and you will see the define add-on call that adds the build processors.
let sfField = sfBuilderProvider.builders.sfField;
let ngModel = sfBuilderProvider.builders.ngModel;
let defaults = [ sfField, ngModel ];
schemaFormDecoratorsProvider.defineAddOn(
'bootstrapDecorator',
'addontest',
'directives/decorators/bootstrap/addontest/addontest.html',
defaults
);ps. sorry for the delay I've been unwell
oh and thanks for making a really detailed and easy to help with issue/plunker :)
Hi!
Sorry for the late response.
First of all there's no need to thank me for raising the issue properly. I thank you for this awesome module.
The defineAddOn method was the key. I didn't realize that it was needed for the new builders to work and thought that it would work with addMapping & createDirective. Lesson learned!
Thanks for taking the time explaining perfectly something that I could read in the docs. That was my mistake.