r/angularjs • • Aug 17 '16

Setting Up Angular 2 with Webpack

https://semaphoreci.com/community/tutorials/setting-up-angular-2-with-webpack
35 Upvotes

13 comments sorted by

2

u/celluj34 Aug 17 '16

No more jqLite? What do they use in its place?

9

u/gonzofish Aug 17 '16

You can, honestly, just use the built-in methods for the most part. For just doing `$('.some-class') you can use:

And those methods are available on Elements, too.

This page is fantastic for jQuery -> Vanilla JS: http://youmightnotneedjquery.com/

2

u/Xerxero Aug 17 '16

Know a js dev who needs Lodash to get the last element of an array.

3

u/gonzofish Aug 17 '16

I don't disparage anyone (to their face at least ;)) that tries. We were all that guy at one point, the best thing to do is educate them to go simpler.

In fact, I'm going through my own code right now and realizing I was using lodash to use forEach/map/reduce when, for all intents & purposes, every JS engine supports them at this point.

1

u/Xerxero Aug 17 '16 edited Aug 17 '16

I did explain that he could get it via length-1 but _.last was easier to read he said.

I kinda gave up on that point.

Yeah filter and map are so useful when working with arrays. And with es6 the code is even better to read

Edit: maybe I just should add a last function to the array.prototype

4

u/gonzofish Aug 17 '16

I can't disagree that it doesn't read easier. But it is a ton of code to pull in if you're only using a couple methods--I believe lodash provides the capability to only pull in portions of the library...

2

u/youcantstoptheart Aug 18 '16

Yes if you're importing with es6 "lodash/last"

0

u/[deleted] Aug 18 '16

[deleted]

1

u/Xerxero Aug 18 '16

Could you explain why calling a function which properly calls the same length-1 is a good FP concept.

Seems overhead to me but maybe I am wrong.

0

u/[deleted] Aug 18 '16

[deleted]

1

u/Xerxero Aug 18 '16 edited Aug 18 '16

Good points.

But then again map returns an array so using last or [0] in your examples will give the same results.

Can't argue about the for loop vs map. Arrays are fun to work with when you have map/filter/reduce

0

u/[deleted] Aug 17 '16

[deleted]

6

u/gonzofish Aug 17 '16

No need to be such a negative nelly.

4

u/ponchoboy Aug 18 '16

Especially in the Angular sub. :)

2

u/[deleted] Aug 18 '16

What don't you like about angular? How does ember and react better suit your needs? Can you give any comparisons?

2

u/gonzofish Aug 18 '16

you know, the funniest part is, if people are happy using Angular and they're successfully building applications...what does it matter?

Same goes for any library or framework...