Search code examples
javascriptangularjsx-editableangular-xeditable

Angular xeditable disable the form


I am using the angular directive: http://vitalets.github.io/angular-xeditable/

And I am trying to get the form displayed as a disabled form, I mean, with all the element disabled (disabled html attribute).

I saw that there is a flag of the form, $waiting set by $setWaiting(), that behaves like that, but there aren't a way to invoke this status as the $show().

There is a way to access to that method from my controller? or in the other hand, how i can extend the directive to make this method public.

Thanks!


Solution

  • I know this is a late answer, but as no one has answered this...

    I think to mess with the $waiting attribute could get you in more trouble that help, as it handles the state of submitting and who know what else.

    The easiest way to accomplish disabling the form-elements is to just use the e-ng-disabled attribute of each editable-control bound to a $scope variable like this:

    <span editable-text="my_model" e-name="name" 
        e-ng-disabled="form_disabled">{{ my_model }}</span>
    

    Here is a fiddle: http://jsfiddle.net/jf2ykddv/5/

    Just for the record, of course it would be nice to be able to disable all controls with some kind of "global" attribute directly through the form, but I don't think thats implemented in angular-xeditable. So this is probably the easiest way.