Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't edit values set by a promise #17

Closed
8bitDesigner opened this issue Oct 4, 2013 · 2 comments
Closed

Can't edit values set by a promise #17

8bitDesigner opened this issue Oct 4, 2013 · 2 comments
Labels

Comments

@8bitDesigner
Copy link

Check out this JSFiddle - http://jsfiddle.net/pP2jZ/1/

I'm assigning a user to the view, which Angular, through some black magic, handles, however when I use angular-xeditable to change the value, the original value is preserved, and my edit is lost.

No 'onbeforesave' or 'onaftersave' callback fires, so I can't intercept the save attempt and return a wrapped promise with the updated value.

I'm not gonna lie, I have no idea how this should be fixed, but, as Angular supports passing promises directly to views, I figured it was worth documenting this at least.

@vitalets
Copy link
Owner

vitalets commented Oct 4, 2013

@8bitDesigner good point!
Assigning value to promise was fixed in current angular 1.2, see angular/angular.js#2854
I've replaced it in your fiddle and now it works:
http://jsfiddle.net/pP2jZ/3/

Also there are two issues you will find:

  1. editable-empty class still applied even if promise resolved with non-empty value. I'll fix it in 0.1.5.
  2. status not shown correctly when using showStatus() method. It's because inside used direct access to $scope.user.status that is pormise and cannot be accessed directly (in fact, value is in $scope.user.$$v ).
    The solution is to put expression right into template - then angular will resolve everything automatically, see my fiddle third sample:
{{ (statuses|filter:{value: user.status||0})[0].text || 'Not set' }}

@8bitDesigner
Copy link
Author

Oh brilliant, thanks, mate!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants