-
Notifications
You must be signed in to change notification settings - Fork 89
Extra hint for Multiplier Filter in "Explore More", chapter 5 #34
Comments
Hi. I am having similar issues ("5 $digest() iterations reached. Aborting!") though my approach was to write a filter that applied to the ingredient list only when it is displayed. I posted a request for more information about the permitted behavior of custom filters on Stackoverflow a few days ago. I posted a follow up on the angular-dart list. Have you been able to make any progress on this? |
No, I haven't come back around to this yet. I completed the rest of the AngularDart tutorial without any trouble. I'll post here if I do figure it out. |
Newly answered in http://stackoverflow.com/questions/21322969/angulardart-custom-filter-call-method-required-to-be-idempotent, and the page now links to that explanation. |
Hi Kathy. Did you notice my second comment to Misko's answer? IMHO, his solution only works if quantity is represented as a double; which means users would get to see multiplied quantities like "2.33333333333 cups of flour" :). In my final solution I had planned to use a special numeric class to handle fractional quantities more nicely. In such a case, even Misko's solution fails to work (at least, according to Misko, until this makes it into Angular Dart). Maybe a less controversial exercise could be proposed at the end of that chapter. |
Nope, I missed that. What exercise would you propose? |
It seems like we are left with choosing a filter that doesn't create new object instances (that aren't |
Thanks, I was able to make it work by filtering only the ingredient. I didn't bother parsing out the quantity or dealing with fractions - I just used a placeholder like in my gist. Going back to the gist (https://gist.github.com/zymsys/8479765) I still want to figure out how it mutated the model. By returning a new array to display I didn't think it had done so. I'll take some more time with it and see if I can sort it out. |
I'm trying to do the Multiplier Filter at the end of chapter 5. The challenge is to write a filter which lets a user enter a multiplier, and have item quantities multiplied by that value on output.
My first attempt failed because the filter was modifying the original recipe instead of a copy for output, so values would keep multiplying over and over again. I tried having the filter construct new recipe models and return a List of those, but that threw it into a loop involving Scope / $watchCollection resulting in an error:
This repeats indefinitely until I stop it. It seems that having the filter return a different list causes it to re-evaluate the ng-repeat, and this goes on forever.
I'm pretty new to Dart and loving it, but I'd really appreciate an extra hint as to how I can better approach this. I've got my current stab at it in this gist: https://gist.github.com/zymsys/8479765
The text was updated successfully, but these errors were encountered: