-
Notifications
You must be signed in to change notification settings - Fork 27.4k
ngOptions required ngModel #7047
Comments
Yeah I dunno, I just asked about this. I don't think it would be unreasonable to emit a warning at the very least. I'm not sure if a patch adding this would be accepted, but it should be pretty trivial to write. Something like link: function(scope, element, attr, ctrls) {
// if ngModel is not defined, we don't need to do anything
if (attr.ngOptions && !ctrls[1]) {
$log.warn("attempting to use ngOptions directive without ngModel!");
return;
} in the ngOptions directive, should be a good way to inform you, I guess. It's kind of tricky though, maybe. |
Brian said it would be worth doing, so maybe we could land a fix for this after all =) Feel free to submit a patch and become a contributor! (caveat: Igor wants to get rid of ng-options, so it might be solved in a different way instead) |
I actually told @reidreid46 to file this, haha. We ran into this today. |
@caitp I can see your point and was about to add what you suggested to the code. However, I don't see any use of "log." or "warn" in the entire Angular's Directive's directory code. My guess is that the convention is not to warn about such things. what do you think? |
I think this might belong in our WIP hinting library. /cc @caguillen214 @ealtenho |
Since Although this is a breaking change (for 1.5) it shouldn't affect anyone in practice since you get no benefit without it. Does anyone have a view on that? |
We can simply remove the |
Closes angular#7047 Closes angular#12840 BREAKING CHANGE: `ngOptions` will now throw if `ngModel` is not present on the `select` element. Previously, having no `ngModel` let `ngOptions` silently fail, which could lead to hard to debug errors. The change should therefore not affect any applications, as it simply makes the requirement more strict and alerts the developer explicitly.
See #12840 |
ngModel is required to see any output put into a ngOptions. If ngModel is ommitted, no options are created, and no warning is given.
Possible to?:
a) not require ngModel, display options regardless
b) or show some kind of warning when ngOptions is used without ngModel
The text was updated successfully, but these errors were encountered: