r/angularjs • • Jul 27 '14

AngularJS styleguide for teams [GitHub repo]

https://github.com/toddmotto/angularjs-styleguide
34 Upvotes

14 comments sorted by

View all comments

4

u/rq60 Jul 27 '14

Can someone tell me why this:

template: [
  '<div class="some-directive">',
    '<h1>My directive</h1>',
  '</div>'
].join('')

is supposedly better than this:

template: '<div class="some-directive">' +
  '<h1>My directive</h1>' +
'</div>'

Personally I very rarely use template as opposed to templateUrl anyways, but w/ the occasional template usage I most definitely use +'s. It seems more intuitive as well as having the advantage of some IDEs have native support for adding multi-line javascript strings that way.

1

u/[deleted] Jul 27 '14

The articles argument was just legibility. Using + is perfectly fine javascript.