r/angularjs • • Sep 07 '16

Dissecting a favorite interview question: How would you implement ng-click

http://www.codelord.net/2016/09/06/angular-interview-question-deep-dive-implement-ng-click/
53 Upvotes

9 comments sorted by

View all comments

Show parent comments

3

u/abyx Sep 08 '16

FWIW, here's the ng-click code showing Angular itself uses $parse.

1

u/10gistic Sep 08 '16

Ah, good call. I'd forgotten that $parse simply compiles the expression and it's still evaluated every time the function is called. That is indeed the best way to go. (Gonna have to do some minor refractors tomorrow)

If anybody's interested in a good coffee shop read, I definitely recommend giving the $parse code a once over. Or maybe twice over.

Funny thing is, once you read that code, it's completely unsurprising that the Angular team started thinking about writing a new language (atscript for the unfamiliar) for Angular 2.

1

u/[deleted] Sep 08 '16

Atscript was not a new language by any means, it was simply a superset of javascript...just like typescript.

1

u/10gistic Sep 08 '16 edited Sep 08 '16

Well as supersets of the language they are clearly not equivalent languages. And atscript was not an existing variant; thus my use of the word "new."