Skip to content

Instantly share code, notes, and snippets.

@tobymurray
Created October 16, 2015 04:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tobymurray/d6538c8044c3930130fa to your computer and use it in GitHub Desktop.
Save tobymurray/d6538c8044c3930130fa to your computer and use it in GitHub Desktop.
Maybe because he tries to use directives to create custom elements too much? I can totally understand. Although that's one of Angular's the biggest selling points, it is also where it sucks the most. It is recommended to put html into a separate resource file then reference to it using templateUrl. Managing these alone will soon become a nightmare if you want to reuse these components.
And CSS for directive - this is a real nightmare. You can't create/expose custom css properties for your element (?!). Let say you have an h1 in your directive and you want to customize it, you will have to give it a custom class. This will lead to many problems. CSS gets leak everywhere. Can't easily set default styling for an element without creating another nightmare with CSS !important. Name will become silly and hard to remember can will easily caused conflict down the road (instead of my-element.label, you will have h1.my-element-label - the former is nicer and won't be affected by a random h1 CSS value somewhere).
React solves this problem and is actually faster at DOM manipulation/generation (although Angular 2 will be as fast if not faster).
All that being said, Angular's out of the box and elegant support/implementation for 2 way binding, injection, events ($emit, $broadcast), filters (orderBy, currency, date etc...) etc... are too good to pass on.
The key is to avoid using its directive system to create custom element (directives like ng-class, ng-repeat etc... are still good because they don't work with html directly - thus make them extremely reusable and powerful still). We shouldn't put much effort into this because everyone knows it sucks and soon will be replaced by Polymer.
Comparing Angular and React, however, is like comparing orange to apple. (Here is a good speech on how they can work together1 in harmony). Although React proves Angular wrong in some areas, Angular still have a lot to offer and React is more mobile focus. Although I like the React team's way of thinking a lot - Rethink Best Practices and Learn Once Write Everywhere, there is no reason to adopt them because Polymer is just so good1 (it does only one thing, and does it so well) and we are not that mobile focus.
RECOMMENDATION: Watch Polymer is just so good1.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment