3 ms·
I think a lot is preference. I think HTML in JS is dirty just like HTML in server side strings. Other people feel the opposite, that putting new tags which are
by exclusiv 11y ago
I think a lot is preference. I think HTML in JS is dirty just like HTML in server side strings. Other people feel the opposite, that putting new tags which are similar to inline onclicks and other events that we moved away from w jQuery is dirty. There is truth to both.
Angular gives a lot of flexibility in code style and structure. You can componetize everything and have all your component files in one folder. You can inline it. Or you can go more MVC style folder structure like I do.
I personally like my html being approachable to junior devs and not being so chopped up and abstracted away from static HTML markup like it might be with React. Not sold on the new tag styles of A2 but I suppose it will just take some adjustment.
- jhall1468 11y ago> Other people feel the opposite, that putting new tags which are similar to inline onclicks and other events that we moved away from w jQuery is dirty. Not even remotely the same thing. HTML has a hierarchical structure which isn't a particularly good structure for a web application. Javascript syntax allows far more control over the hierarchy. Your example is akin to saying putting a tank in an airplane is the same thing as putting an airplane in a tank. > You can inline it. Pretty thin separation between inline templates and JSX. But then, I've never understood why people think putting their template in a different file is somehow separation of concerns. > I personally like my html being approachable to junior devs and not being so chopped up and abstracted away from static HTML markup like it might be with React. Oh it's abstracted, with completely invalid HTML syntax and template variables. That's not to say that it's bad, I quite like the simplicity of the event/binding syntax of Angular 2. But JSX and Angular Templates are just two sides of the same coin.
- slmyers 11y ago> Not even remotely the same thing. HTML has a hierarchical structure which isn't a particularly good structure for a web application. Is there a "good" structure for a web application that jumps to your mind?
- jhall1468 11y agoYes, isolated components with as few components being aware of the application state as possible. This is the fundamental structure if a redux app, which is effectively the point if Web Components. Throwing on click tags or jquery selectors on a huge HTML document is not a good structure.
- exclusiv 11y ago> Not even remotely the same thing. HTML has a hierarchical structure which isn't a particularly good structure for a web application. Javascript syntax allows far more control over the hierarchy. I agree with you on the control but my point was that a lot of people that dislike Angular don't like the idea of putting tags on HTML elements which is very reminiscent to inline onclicks and the hackish approach to apps from yesteryear. onclick="doSomething()" versus ng-click="controller.doSomething()" Sure, there's a lot more under the hood with Angular but it looks and feels similarly and it scares some people away toward other approaches. JS used to have a lot of inline code back in the day. Then jQuery came along and devs moved their JS into separate files but everything was still tied to elements and very frail. It was terrible for apps of any complexity. Now we have a ton of options and there is no consensus. However, maintainability is easier and building robust front-ends that don't break when someone moves a div or renames a class is not difficult anymore. Angular is my favorite but I'm also liking what I'm seeing from Vue for a lot of applications.
- Macha 11y ago> But then, I've never understood why people think putting their template in a different file is somehow separation of concerns. We can point our UX designer at this separate file and he can understand it, which would not be the case if it's buried in JS?