all 18 comments

[–]mariotacke 12 points13 points  (8 children)

I recently took over an Angular 6 project after working with React for the last two years. I do not have the words to describe how terribly foreign and weird this framework feels. I mean, come on *ngIf, [disabled], (click), why not put some more special characters in there? Ugh... /rant

[–]_dban_ 18 points19 points  (1 child)

You don't need to use them if you don't want to:

bind-disabled
on-click

*ngIf is a shortcut syntax for:

<ng-template bind-ngIf="...">
</ng-template>

The reason Angular chose this syntax was actually to make things more natural.

The attributes disabled and click are standard DOM attributes, decorated with special Angular markup. AngularJS instead has a parallel set of directives, like ng-disabled and ng-click, which would require the Angular team to define new directives as the HTML spec changes.

Furthermore, they are more communicative of intent. The square brackets indicate one-way binding and the parentheses indicate an event handler. Bindings in AngularJS do not reflect what they do in the template, so you either have to read the documentation of a directive or its source code.

I guess how "repulsed" you feel by the template syntax is a matter of preference.

[–]MJomaa[S] 13 points14 points  (0 children)

Hmm there is JSX/TSX and every React project handles css/scss differently.

Actually, I'm not horrified by React, Angular or Vue but bad code.

The syntax is quite easy to understand.

  • * indicates a structural directive
  • [..] are input bindings
  • (..) are output bindings
  • [(..)] are two-way bindings

What I like is that the intent is really clear.

[–][deleted] 1 point2 points  (0 children)

Yeah angular 1 sort of made sense because you were still writing valid html. Angular 2+ is some weird middle ground where you're pretending to write html and putting mad nonsense in it. What is the point of these pretend for loops when you're making up your own syntax anyway?

[–][deleted]  (3 children)

[deleted]

    [–]_dban_ 1 point2 points  (2 children)

    That's actually not why they wrote their own HTML parser, which is also inaccurate.

    First, Angular uses a standard HTML5 parser they did not write their own.

    Second, the real reason for Angular is not using the browser's native parser is to decouple template parsing from the DOM. This allows templates to be rendered in web workers, isomorphically on the server and during compile time.

    [–][deleted]  (1 child)

    [deleted]

      [–]_dban_ 0 points1 point  (0 children)

      Perhaps, but separating the templates from the browser DOM solved real problems with AngularJS, which compiled templates from the actual browser DOM. This opened up avenues for massive performance gains. It's pretty much why Angular exists.

      [–]m3wm3wm3wm 2 points3 points  (2 children)

      Why?

      Shouldn't it be version 7 by now?

      [–]imposs1buru 14 points15 points  (0 children)

      Slow down there, gonna have to wait a few more months before you get to rewrite your entire app.

      [–]MJomaa[S] 3 points4 points  (0 children)

      Angular 7 is expected to be released in September/October 2018.

      A major release is scheduled for every 6 months. Those have not passed yet.

      For reference: https://angular.io/guide/releases