I’m trying to disable an option within a select input, based on the parent context. I know that repeat.for creates a new bindingContext on the fly and I should be able to access the overrideContext for properties in the parent.
Example: I have a meal planner, a select represents the days of the week, when assigning a meal for a day I want to disable that specific day from the available options.
I’m trying both $parent and also straight access to the override context. Plus im getting some sintax errors in my disabled binding. Has anyone do something like this. Thanks.
I think you are just missing model.bind=“null” on both of the default options? If i select an object and move back to original the button is enabled when it should not be.
Thanks for the taking the time brandon, yes that was definetely a bug. However what I wanted to achieve is to disabled the days from the drppdown that already have been a meal assigned to. So for example if I say Monday I will eat fish … then the Monday option should be disabled in the select afterwards. Do I make sense?
As @Stuart suggested you could also include something on the object itself so the observer knows when to disable rather than be signaled to do so. To achieve this you would need to store an array of valid meals on each day, days on each meal, or a simple boolean set on load.
Adjusting the canEatIt method to also pass in the day will make signaler not required. I updated the pen to reflect these changes after talking with @bigopon.