38

Didn't it take us years to stop writing javascript and html embedded? Is it just me or are we going back where we started? It's all a mix now!

Comments
  • 4
  • 5
    The difference is, this is html embedded in js 😁

    Try it, you will love it
  • 6
    Use templateUrl instead. Keep your html and JavaScript in separate files as recommended.
  • 3
    Ohh wait, this isnt react
  • 0
    @ruddix This appears to be Razor, which is HTML and C#.
  • 10
    This is Angular 2-4 in typescript.
  • 0
    @axelbr Hmm, the syntax is quite similar then.
  • 1
    Its the"Tour of heroes"-tutorial.
    Pretty good!
    https://angular.io/docs/ts/...
  • 0
    @JTBringe I don't know Razor. But afaik Typescript is a Microsoft thing. Maybe this is the reason.
  • 1
    @axelbr It's probably because Angular uses an MVC design pattern, just like ASP.NET can, and you fetch properties from somewhere and mix it with HTML. Hence why it's so similar.
  • 3
    As far as I can tell this is a template, which is meant to be combined because you have to have some kind of placeholders in the html for actual values, the point is to not have complex/business logic inside the presentation layer. The presentation layer itself does consist of HTML and JS, though... Granted, it's normally separated in different files, but for such a small template it might br worth combining it if it doesn't violate any other rules of the project
  • 0
    @Bikonja exactly. you can implement sophisticated logic in your html template. the component holds the data and manages the template, services etc.
  • 2
    Ffs just take a screenshot
  • 0
    Well that's characteristic for Angular template. Like Rails 😉
  • 1
    @ruddix welcome to devRant. Have your first ++
  • 1
    We have the html in a seperate file and use

    template: require('relative/path')

    in the @Component section of the ts file, much cleaner in my opinion!
  • 0
    Try Vue.js with .vue files where HTML, JS and CSS are nicely separated.
  • 1
    Use TemplateUrl! It's much easier!
  • 3
    While it's true that in the old days we had all mixed up with inline styles (or even font tags) and JS in attributes, I think the current trend suggests that we did the split at the wrong place. Instead of splitting by technology or layer (HTML for view, JS for fancy interaction, CSS for layout and styling) many people now think the we should instead split by logical components, features etc. This is the reason for all the new fancy Web components based JS frameworks. In backend we see the same: microservices are small isolated features stretching alongside most layers (except for view maybe) . I think the next step will be tight binding of components and corresponding microservices.
Add Comment