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

Commit ef894c8

Browse files
fix(ngOptions): ngModel is optional
1 parent 30b4813 commit ef894c8

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/ng/directive/ngOptions.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ var ngOptionsDirective = ['$compile', '$parse', function($compile, $parse) {
350350
return {
351351
restrict: 'A',
352352
terminal: true,
353-
require: ['select', 'ngModel'],
353+
require: ['select', '?ngModel'],
354354
link: function(scope, selectElement, attr, ctrls) {
355355

356356
// if ngModel is not defined, we don't need to do anything

test/ng/directive/ngOptionsSpec.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,18 @@ describe('ngOptions', function() {
151151

152152
it('should throw when not formated "? for ? in ?"', function() {
153153
expect(function() {
154-
compile('<select ng-model="selected" ng-options="i dont parse"></select>')(scope);
154+
compile('<select ng-model="selected" ng-options="i dont parse"></select>');
155155
}).toThrowMinErr('ngOptions', 'iexp', /Expected expression in form of/);
156156
});
157157

158158

159+
it('should have optional dependency on ngModel', function() {
160+
expect(function() {
161+
compile('<select ng-options="item in items"></select>');
162+
}).not.toThrow();
163+
});
164+
165+
159166
it('should render a list', function() {
160167
createSingleSelect();
161168

0 commit comments

Comments
 (0)