This week's book giveaway is in the Java in General forum.
We're giving away four copies of Event Streams in Action and have Alexander Dean & Valentin Crettaz on-line!
See this thread for details.
Win a copy of Event Streams in Action this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

[AngularJS] - the benefits (?) of "extending HTML"

 
whippersnapper
Posts: 1843
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I recently went to a presentation/discussion on AngularJS, about which I know only a little. (I've been investigating various trendy JavaScript technologies lately.)

Anyhow, a couple times people mentioned that "AngularJS allows you to extend HTML" (implying that this was a very good thing). So I asked the question "So why is extending HTML a good thing?" Some wit in the audience snarked out in response, "When hasn't extending HTML been a good thing?" Things devolved and nobody addressed my question. (And I chose not to engage the wit. (Am I getting old?))

So of course it would be unfair of me to expect anyone to defend someone else's statement, but I would be curious to hear what people here think on the topic. Does AngularJS actually "allow you to extend HTML"? And if it does, why is this a good thing?

 
Marshal
Posts: 67273
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Off the top of my head:
  • Because the template is still valid HTML, validators can be used.
  • There's no yet another proprietary template markup language to learn.
  • IDEs don't need plugins to deal with yet another proprietary template markup language.
  • Everyone already knows (at least rudimentary) HTML.
  • The template you see during development is the same thing you see in the browser at debug time.



  • (The latter is the most important to me.)
     
    Bartender
    Posts: 2968
    6
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    Bear Bibeault wrote:Off the top of my head:

  • ...
  • There's no yet another proprietary template markup language to learn.
  • ...
  • The template you see during development is the same thing you see in the browser at debug time.

  • ... and as a result the rendered HTML, once Angular has done it's thing, tends to look nothing like the HTML loaded from the server - and that can take some getting used to.

    Michael Matola wrote:Does AngularJS actually "allow you to extend HTML"? And if it does, why is this a good thing?


    My take is that "extending the HTML" is a tagline that is primarily associated with AngularJS 1.x. Custom directives make it possible to cleanly factor out HTML/JavaScript (i.e. structural + behavioral) fragments for effective reuse (typically at the cost of additional server round trips and browser-side processing). AngularJS 2.x is going to rely much more heavily on Web Component technology for that - so I'm expecting the "extend HTML" aspect to be de-emphasized in the future.
     
    Bear Bibeault
    Marshal
    Posts: 67273
    170
    Mac Mac OS X IntelliJ IDE jQuery Java
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    Peer Reynders wrote:

    Bear Bibeault wrote:Off the top of my head:

  • ...
  • There's no yet another proprietary template markup language to learn.
  • ...
  • The template you see during development is the same thing you see in the browser at debug time.

  • ... and as a result the rendered HTML, once Angular has done it's thing, tends to look nothing like the HTML loaded from the server - and that can take some getting used to.


    I'll somewhat disagree, but it does heavily depend on how one uses Angular and marks up their HTML. Certainly, an Angular template looks a lot more similar in the browser to its source than a JSP or other server-side templating engine.

    That said, I tend to use attribute directives much more than element directives, which helps to keep my templates recognizable in the browser. As with everything, YMMV.

    (Lest I come across as an AngularJS fanboy, there's a much longer list of things I dislike about it than I like about it, but the templates aren't one of the things that bother me all that much.)
     
    Michael Matola
    whippersnapper
    Posts: 1843
    5
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    Peer Reynders wrote:
    My take is that "extending the HTML" is a tagline that is primarily associated with AngularJS 1.x. Custom directives make it possible to cleanly factor out HTML/JavaScript (i.e. structural + behavioral) fragments for effective reuse <...>



    One of the people who spoke of extending the HTML went on to show a portion of his company's extensive library of custom directives, so what you say helps explain their view on things.

    (typically at the cost of additional server round trips and browser-side processing). AngularJS 2.x is going to rely much more heavily on Web Component technology for that - so I'm expecting the "extend HTML" aspect to be de-emphasized in the future.

    Bear Bibeault wrote:(Lest I come across as an AngularJS fanboy, there's a much longer list of things I dislike about it than I like about it, but the templates aren't one of the things that bother me all that much.)



    Oh, I was definitely in the company of AngularJS fanpeople last night. Angular and Gulp on the rise! Backbone and Grunt tanking!

    (A mobile developer said he was fascinated to learn that "web apps still seem relevant"!)
     
    Bear Bibeault
    Marshal
    Posts: 67273
    170
    Mac Mac OS X IntelliJ IDE jQuery Java
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    Michael Matola wrote:Oh, I was definitely in the company of AngularJS fanpeople last night. Angular and Gulp on the rise! Backbone and Grunt tanking!


    AngularJS is definitely enjoying its place in the sun right now. Both my current and previous jobs were in AngularJS web apps, and the majority of positions I've considered in the past year were focused on SPAs using AngularJS.

    With regards to Gulp, I will personally never understand the propensity for the web development community to rally around a system for which it seems impossible to find credible documentation.

    (A mobile developer said he was fascinated to learn that "web apps still seem relevant"!)


    People who cannot see beyond the needs of their immediate ecosystem automatically have their credibility discounted.
     
    Peer Reynders
    Bartender
    Posts: 2968
    6
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    Bear Bibeault wrote:Lest I come across as an AngularJS fanboy


    I don't think there was any danger of that

    Bear Bibeault wrote:there's a much longer list of things I dislike about it than I like about it.


    Frankly I find your restraint admirable given that you had to repeatedly work with a tool that you are not fond of ... a lesser person would have launched into a tirade.

    AngularJS only came to my attention because I became interested in full-stack JavaScript which lead to MEAN, which lead to AngularJS. Interestingly the best (kind of) MEAN book I have come across is Ethan Brown's Web Development with Node and Express and he bypasses AngularJS entirely in favour of using Handlebars - possibly because AngularJS needs to be covered in a separate book (or more).

    Michael Matola wrote:Angular and Gulp on the rise! Backbone and Grunt tanking!


    Given that Grunt and Gulp are node-based I am constantly amazed how people use them for even the most trival tasks that are much more easily accomplished with npm scripts. How to Use npm as a Build Tool.

    Michael Matola wrote:A mobile developer said he was fascinated to learn that "web apps still seem relevant"!


    Businesses aren't interested in infinitely expending redundant effort on multiple platforms (Web, iOS, Android, etc.). For the time being they do because the platform specific experience is perceived to give them a competitive advantage. Some people seem to think that MeteorJS is a possible solution but similar systems have typically been plagued by the "lowest common denominator syndrome". So for the time being "the Web" still seems to be the most applicable unifying platform - "the Web" will continue to become more "mobile-friendly" and the mobile browsers and their integration needs to keep up ...
     
    Consider Paul's rocket mass heater.
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!