Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

fix(ngOptions): throw if ngModel is not present #12840

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions src/ng/directive/ngOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -395,14 +395,11 @@ var ngOptionsDirective = ['$compile', '$parse', function($compile, $parse) {
return {
restrict: 'A',
terminal: true,
require: ['select', '?ngModel'],
require: ['select', 'ngModel'],
link: function(scope, selectElement, attr, ctrls) {

// if ngModel is not defined, we don't need to do anything
var ngModelCtrl = ctrls[1];
if (!ngModelCtrl) return;

var selectCtrl = ctrls[0];
var ngModelCtrl = ctrls[1];
var multiple = attr.multiple;

// The emptyOption allows the application developer to provide their own custom "empty"
Expand Down
4 changes: 2 additions & 2 deletions test/ng/directive/ngOptionsSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,10 @@ describe('ngOptions', function() {
});


it('should have optional dependency on ngModel', function() {
it('should have a dependency on ngModel', function() {
expect(function() {
compile('<select ng-options="item in items"></select>');
}).not.toThrow();
}).toThrow();
});


Expand Down