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

ng-option should work when it contains newlines. #4142

Closed
jamie-pate opened this issue Sep 24, 2013 · 4 comments
Closed

ng-option should work when it contains newlines. #4142

jamie-pate opened this issue Sep 24, 2013 · 4 comments

Comments

@jamie-pate
Copy link

It seems like we should be able to do this

<select ng-options="o.name as o.name
                    for o in model.options
                    | filter:{$hide:'!true'}"></select>

but it throws

Expected expression in form of '_select_ (as _label_)? for (_key_,)?_value_ in _collection_' but got 'o.name as o.name
                    for o in model.options
                    | filter:{$hide:'!true'}'.

I could prepare a pr if this seems like something that should be supported.
(Would I need to count \n as whitespace when parsing all expressions? Is this a larger issue with expressions in general? Are there any horrible horrible failure cases this would cause?)

@forivall
Copy link
Contributor

Newlines are allowed in most places in the directive; they are just not allowed in the _collection_ part of the expression.

This

<select ng-options="o.name as o.name
                    for o in
                    model.options | filter:{$hide:'!true'}"></select>

works just fine.

Most expression regexes for directives contain plenty of \ss, so I don't think this is a larger issue.

@jamie-pate
Copy link
Author

Hmm, good to know, I'd still expect whitespace to be whitespace though...
The issue just became much narrower and less important though :)

On Tue, Sep 24, 2013 at 11:34 AM, Jordan Klassen
notifications@git.luolix.topwrote:

Newlines are allowed in most places in the directive; they are just not
allowed in the collection part of the expression.

This

works just fine.


Reply to this email directly or view it on GitHubhttps://github.com//issues/4142#issuecomment-25030653
.

@petebacondarwin
Copy link
Contributor

Feel free to send in a well crafted, CLA signed, PR for this!

esarbanis added a commit to esarbanis/angular.js that referenced this issue Sep 26, 2013
Changed the regular expression to allow trailing spaces and new lines after _collection_

Closes angular#4142
@esarbanis
Copy link
Contributor

I believe this is resolved with #5602, maybe you should close it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants