Stereo99
Stereo99

Reputation: 232

Strange object in Angular JS - explanation?

I was messing around in the console and came across a strange object: ng-1392763474770

Logging it returned:

ReferenceError: ng is not defined

What exactly is this? I couldn't bring anything up through my searches.

P.S. This page is just for demo, there is no html.

Upvotes: 2

Views: 312

Answers (1)

Ilan Frumer
Ilan Frumer

Reputation: 32367

This number is a date timestamp:

Date(1392763474770)
"Wed Feb 19 2014 01:49:41 GMT+0200 (IST)"

The reason why you get ReferenceError: ng is not defined is because it's not a valid javascript, instead you can use the object bracket notation:

 element['ng-1392763474770']

This is a JQLite.expando , from the source code:

 jqName = JQLite.expando = 'ng-' + new Date().getTime()

jqLite uses it to cache element's data and avoid circular references.

See this: what is the meaning of jquery random attributes in html ? [expando attribute]

Upvotes: 5

Related Questions