diff --git a/src/ng/directive/select.js b/src/ng/directive/select.js index 3dbb5b8e52d5..62e460c5289f 100644 --- a/src/ng/directive/select.js +++ b/src/ng/directive/select.js @@ -129,7 +129,7 @@ var ngOptionsDirective = valueFn({ terminal: true }); // jshint maxlen: false var selectDirective = ['$compile', '$parse', function($compile, $parse) { //0000111110000000000022220000000000000000000000333300000000000000444444444444444000000000555555555555555000000066666666666666600000000000000007777000000000000000000088888 - var NG_OPTIONS_REGEXP = /^\s*(.*?)(?:\s+as\s+(.*?))?(?:\s+group\s+by\s+(.*))?\s+for\s+(?:([\$\w][\$\w]*)|(?:\(\s*([\$\w][\$\w]*)\s*,\s*([\$\w][\$\w]*)\s*\)))\s+in\s+(.*?)(?:\s+track\s+by\s+(.*?))?$/, + var NG_OPTIONS_REGEXP = /^\s*([\s\S]+?)(?:\s+as\s+([\s\S]+?))?(?:\s+group\s+by\s+([\s\S]+?))?\s+for\s+(?:([\$\w][\$\w]*)|(?:\(\s*([\$\w][\$\w]*)\s*,\s*([\$\w][\$\w]*)\s*\)))\s+in\s+([\s\S]+?)(?:\s+track\s+by\s+([\s\S]+?))?$/, nullModelCtrl = {$setViewValue: noop}; // jshint maxlen: 100 diff --git a/test/ng/directive/selectSpec.js b/test/ng/directive/selectSpec.js index 835919497a21..6fcd1fe05f82 100644 --- a/test/ng/directive/selectSpec.js +++ b/test/ng/directive/selectSpec.js @@ -708,6 +708,31 @@ describe('select', function() { expect(sortedHtml(options[0])).toEqual(''); }); + it('should allow expressions over multiple lines', function() { + scope.isNotFoo = function(item) { + return item.name !== 'Foo'; + }; + + createSelect({ + 'ng-options': 'key.id\n' + + 'for key in object\n' + + '| filter:isNotFoo', + 'ng-model': 'selected' + }); + + scope.$apply(function() { + scope.object = [{'id': 1, 'name': 'Foo'}, + {'id': 2, 'name': 'Bar'}, + {'id': 3, 'name': 'Baz'}]; + scope.selected = scope.object[0]; + }); + + var options = element.find('option'); + expect(options.length).toEqual(3); + expect(sortedHtml(options[1])).toEqual(''); + expect(sortedHtml(options[2])).toEqual(''); + }); + describe('binding', function() { it('should bind to scope value', function() {