Reputation: 452
My website has several forms where name related info is collected (first, last, suffix, etc). Instead of adding/formatting these fields on each controller on the various pages, I decided to create a simple html file that has these fields created. This html file simply contains 4 text inputs.
The plan was to use this html file as a template and thus easily be able to incorporate the same name related fields in multiple forms very quickly.
I created a JSBin: http://jsbin.com/nenepuyalu/1/edit?html,js,output
In this example, I am not including my various wrappers or validation logic (too much of a pain). That said, you can see where I create a new type nameInputGroup
. This type is a templateUrl pointing towards input-group-name.html
which has two text inputs.
I am having issues with making these two inputs validate. Since they are not added directly to the fields
array I am not sure how I flag the fields to have the required
or min/max
validation requirements.
Any suggestions? Or is there a better way to accomplish this?
Upvotes: 0
Views: 468
Reputation: 29081
If I understand your use-case correctly, you simply want to be able to not duplicate yourself in the several places that you have the same series of fields. There are several ways to do this. Here's what I would recommend: http://kentcdodds.jsbin.com/mokeza/edit?html,js,output
Basically, you place your configuration in a separate file, then you concat
those fields with the extra fields you want (you can chain concat
calls).
Upvotes: 0