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

ngRepeat does not support free-style code #5537

Closed
@TWiStErRob

Description

@TWiStErRob

The following uses of ng-repeat result in some kind of error, however they should be valid if parsed by $parser:

Extraneous spaces

<div ng-repeat="item  in items">{{item}}</div>

note: two spaces after item.

Multiline code

<div ng-repeat="item in items
                | filter: 'isShown'
                | orderBy: 'name'
                track by $index">
{{item}}
</div>

The regular expression at ngRepeatDirective's link is too restrictive.

To fix the first problem don't be greedy when matching the variable name ( \1: (.+) VS (.+?) [probably \4 should be non-greedy too, though I could not come it with anything to break it]:

/^\s*(.+?)\s+in\s+(.*?)\s*(\s+track\s+by\s+(.+)\s*)?$/

To fix the second problem, use "dot matches newline"/"multiline mode", i.e. /regex/m:

/^\s*(.+?)\s+in\s+(.*?)\s*(\s+track\s+by\s+(.+)\s*)?$/m

I was trying to trick angular.js to ignore them in different ways, for example declarding ng-repeat as non-CDATA in DTD to make it drop the whitespaces, but it didn't work. See XHTML 1.1 @ 4.7 and XHTML @ 3.3.3: everything undeclared is CDATA, hence no normalization.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions