Comment

Comment by ianstormtaylor

Every time I see someone explaining the Angular API I cringe because it seems like an API that has no respect for the user actually forced to learn it. Everything seems so hostile. For example:

  restrict: 'E'
Good luck knowing what that does at first glance. Instead why couldn't it have been simply called:

  type: 'element'
Or another one, surely the default for creating new custom elements would be to always replace the element, so we shouldn't have to manually set:

  replace: true
But we do because not all directives default to replacement, so maybe they thought it would get confusing if some defaulted to it. Instead they probably should have realized that the problem wasn't with the default for replacement, it was that everything was shoe-horned into a "directive". Why not have an easy shortcut for create elements vs. creating events or attributes...

  app.element('button', ...

  app.attribute('toggle', ...

  app.event('scroll', ...
And then you can have sensible defaults for each one without the user getting extremely confused. I would absolutely expect elements to replace by default.

I'm sure this is an oversimplification, but surely there have to be less implementor-hostile ways to write these features. For example, even after reading the article I still have no idea what setting this on an attribute does:

  scope: {
    toggle: '='
  }
That's ridiculous. I don't think there are enough designers on the Angular team.

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton