From 518bf019f12578d4d6c0c180dd3047eaef3122cd Mon Sep 17 00:00:00 2001 From: Stephen Barker Date: Mon, 9 Feb 2015 15:29:42 -0500 Subject: [PATCH] feat(ngOptions): add support for disabling an option This patch adds support for disabling options based on model values. The "disable when" syntax allows for listening to changes on those model values, in order to dynamically enable and disable the options. The changes prevent disabled options from being written to the selectCtrl from the model. If a disabled selection is present on the model, normal unknown or empty functionality kicks in. closes #638 --- src/ng/directive/ngOptions.js | 75 +++++++++++++------- test/ng/directive/ngOptionsSpec.js | 107 +++++++++++++++++++++++++++++ 2 files changed, 159 insertions(+), 23 deletions(-) diff --git a/src/ng/directive/ngOptions.js b/src/ng/directive/ngOptions.js index 55b8d42faa5d..85a725069ee0 100644 --- a/src/ng/directive/ngOptions.js +++ b/src/ng/directive/ngOptions.js @@ -94,15 +94,20 @@ var ngOptionsMinErr = minErr('ngOptions'); * * `label` **`for`** `value` **`in`** `array` * * `select` **`as`** `label` **`for`** `value` **`in`** `array` * * `label` **`group by`** `group` **`for`** `value` **`in`** `array` + * * `label` **`disable when`** `disable` **`for`** `value` **`in`** `array` * * `label` **`group by`** `group` **`for`** `value` **`in`** `array` **`track by`** `trackexpr` + * * `label` **`disable when`** `disable` **`for`** `value` **`in`** `array` **`track by`** `trackexpr` * * `label` **`for`** `value` **`in`** `array` | orderBy:`orderexpr` **`track by`** `trackexpr` * (for including a filter with `track by`) * * for object data sources: * * `label` **`for (`**`key` **`,`** `value`**`) in`** `object` * * `select` **`as`** `label` **`for (`**`key` **`,`** `value`**`) in`** `object` * * `label` **`group by`** `group` **`for (`**`key`**`,`** `value`**`) in`** `object` + * * `label` **`disable when`** `disable` **`for (`**`key`**`,`** `value`**`) in`** `object` * * `select` **`as`** `label` **`group by`** `group` * **`for` `(`**`key`**`,`** `value`**`) in`** `object` + * * `select` **`as`** `label` **`disable when`** `disable` + * **`for` `(`**`key`**`,`** `value`**`) in`** `object` * * Where: * @@ -116,6 +121,8 @@ var ngOptionsMinErr = minErr('ngOptions'); * element. If not specified, `select` expression will default to `value`. * * `group`: The result of this expression will be used to group options using the `` * DOM element. + * * `disable`: The result of this expression will be used to disable the rendered `