Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save zachlysobey/f55aa14daca3f3eda6fa to your computer and use it in GitHub Desktop.
Save zachlysobey/f55aa14daca3f3eda6fa to your computer and use it in GitHub Desktop.
Angular 1 Directive with ES6 Multi-line string template inline.
(function() {
'use strict';
angular
.module('myModule')
.directive('myDirective', myDirective);
const template = `
<div class="my-directive-template">
<h1>Using multi-line Strings for templates</h1>
<p>
Of course, this will currently only work
when transpiling the ES6 code to ES5 with
something like Babel
</p>
</div>
`;
function myDirective() {
return {
template: template,
restrict: 'E'
};
}
}());
@zachlysobey
Copy link
Author

Thats a neat spin on this idea!
I think you're missing a controller: key there though:
image

@chukonu
Copy link

chukonu commented Mar 3, 2016

Omitting the key here is actually fine, thanks to the shorter syntax in ES6.
:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment