Pasvaz/bindonce

bo-value does not work with ng-model

dbkingsb opened this issue · 4 comments

In this fiddle, change the ng-value to bo-value, and you'll see the demo fail.
http://jsfiddle.net/NHVBW/

I can get the intended outcome (a "unwatched" value) by removing the watcher from ng-value's source, so it seems like bo-value should be able to accomplish the same thing.

I haven't spent the time to figure out how ng-model works, but my guess is that this is a order-of-events issue between ng-model and bo-value; when I inspect the rendered HTML, bo-value successfully added the 'value' attribute.

I tried the demo, bo-value actually set the value of the input as expected, if you inspect the DOM you can see the $index value inside the input. Apparently the problem is that ng-model ignore it. It may be a problem with priority but it's just a guess, I need to investigate more and fix it, at the moment I'll label this issue as bug.

It seems like attrs.$observe is missing link between bo-value and ng-model. At any rate, this commit fixes it, and should fix other issues that might come up.

@mikestopcontinues it sounds good, did you test attrs.$set enough to consider it stable?

I put it into use at work this morning, where we use bindonce for almost everything. It's stable.