M4cJunk13 M4cJunk13 - 1 year ago 42
AngularJS Question

Strange variable NGREPEAT_SOURCE_RE

I came a cross this line of code in a fiddler. I have never seen this before, can anyone explain what exactly it is doing and why the var NGREPEAT_SOURCE_RE = a comment?

Thank you!

var NGREPEAT_SOURCE_RE = '<!-- ngRepeat: ((.*) in ((.*?)( track by (.*))?)) -->';

Link: https://jsfiddle.net/g/3SH7a/

ash ash
Answer Source

Looks to me like that code is a regular expression designed to match the default comment angular puts in to the html when expanding an ng-repeat:

<!-- ngRepeat: <item> in <iterator> track by <someUniqueProp> -->

Where <iterator> and track by <someUniqueProp> are optional, hence the ? in the regex. So someone's using it to search for ng-repeats in their html. :)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download