So I am trying to replicate a simple_form_for like alternative in angularjs
to make it easy to build forms.
Here is an input example
%div{data: {sf_field: "text", ng_model: "user.name", label: "Name", help:
"What is your name?", placeholder: "enter your name", ng_required: "true"}}
Now my issue is I need to be able to take any parameter and pass it to the
input. For instance the ng_required attribute. It would be silly to make my
directive have a scope variable for each possible attribute because what
happens if I add soemthing like angular-payments which has its own
attributes you can drop on an input. Now I already through about maybe just
using transclude and putting the input code in myself but I really was
hoping to be able to build a dynamic form input directive that would
manage, hints, errors / validations, etc
Note, this generates a bunch of HTML
<div class="input-wrapper text" data-ng-class="{'field-error': isError}">
<label class="field-wrap">
<div class="label ng-binding">
Name
<i class="help-icon fa fa-question-circle ng-scope"
data-ng-show="help" data-tooltip="What is your name?"></i>
</div>
<div class="field">
<!-- ngInclude: fieldTemplate --><div data-ng-include="fieldTemplate"
class="ng-scope"><input data-ng-model="ngModel" placeholder="enter your
name" type="text" class="ng-scope ng-pristine ng-valid" name="name">
</div>
</div>
</label>
</div>
Anyone with an suggestions on the best way to pass any attribute through
would be greatly appreciated. I already thought about putting the "dynamic"
attributes inside like a attrs parameter but I don't know how to make them
work. That works for certain things but expressions/functions don't work.
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.