Hacker News new | ask | show | jobs
by Bilal_io 1073 days ago
Angular template syntax is correct HTML syntax. It's nothing like the examples abovd.
2 comments

https://angular.io/guide/binding-overview

Haven't looked at angular since 2015 to be honest, but it still seems like they do weird html stuff to me, such as:

<ul> <li *ngFor="let customer of customers">{{customer.name}}</li> </ul> or <label>Type something: <input #customerInput>{{customerInput.value}} </label>

Angular will soon be migrating to the Svelte style of conditional flow control. https://github.com/angular/angular/discussions/50719
I agree with you, it looks weird, but my point was that it's correct HTML syntax, even though you cannot expect it to work if you open an Angular template in a browser, but an HTML parser can tell you it's syntactically correct.
> HTML parser can tell you it's syntactically correct

Which is completely useless because your website doesn't work anyway

This is true of Svelte's syntax as well, is it not?
Not really on:click is not valid HTML
Oh, that makes sense, I get you now.
You're telling me on:click={toggle} is nothing like (click)="toggle()"?
it's not. `toggle` is a pointer to a function name and "toggle()" appears to be an expression which is parsed and then executed (scary).

you can on on:click={() => toggle()} in svelte which is more similar, but it isn't parsed and executed, it is a pointer to an anonymous function which is directly executed.

on:click={toggle()} in svelte would run the function immediately (probably not what you want) and return the result as the handler for the on:click

so quite different, really.

Not a pointer to a function. In JS, functions are first class objects. You might as well say toggle() is an invocation of a pointer to a function.

<div onclick="toggle"> has existed since the dawn of JavaScript in Netscape Navigator 2.0 Beta Gold. Your complaint about the syntax is in fact baked into the foundations of the web.

One is syntactically correct HTML, and the other is not. That's was the only point of my comment