vitalets / angular-xeditable

Edit in place for AngularJS
http://vitalets.github.io/angular-xeditable
MIT License
1.91k stars 403 forks source link

Can't bind the e-form attribute to a controller property instead op scope. #413

Closed bramcordie closed 8 years ago

bramcordie commented 8 years ago

I'm trying to bind the e-form attribute to a controller property instead of having it float around on scope. The following plunkr demonstrates what I'm trying to do: http://plnkr.co/edit/KAYtHhN5tL92xec4L4sP.

Am I using the right syntax or is this simply not possible?

The scope of the actual use-case is a little more involved so that's why I'm trying this alternative. Directly putting the property on scope results in the directive not loading. There is no feedback in the console so I'm still figuring out what's going wrong. The controller as syntax might be causing problems?

ljfolino commented 8 years ago

The issue seems to be you are missing the form attribute. You need to define a form and each input needs to point to the form using e-form. Look at the example on the page for forms.

bramcordie commented 8 years ago

Fiddle was messed up so I switched it with a working plunker: http://plnkr.co/edit/KAYtHhN5tL92xec4L4sP. @ljfolino I'm just editing the example I found in the documentation. Do you mean a form element? A form element would not make sense in the context that I want to use the editable element.

ljfolino commented 8 years ago

I don't think you can directly attach the form to the controller. The form element allows you to bind multiple controls to the form element. You could then onshow of the form bind the form to the controller at that point.

You may be able to bind the form directly by defining it using bindable-form and giving it a name and using in the controller ctrl.form = <nameofform>. I have not done that and not sure if it would work.

mitcht commented 8 years ago

This is not an actual issue with the project. Questions such as this are better suited to be posted on sites like stackoverflow.com, using their Q/A format. Thanks.