I am trying to make a directive template multiline. Is this possible?
myApp.directive('myDir', function() {
return {
restrict: 'E',
template: '<div>
|Hello,
|{{test}}!
|</div>'
};
});
Here's a Fiddle to see what I mean.
An inline HTML template for a component is defined using template config in @Component decorator, as shown below. It can be a single line template wrapped inside double quotes or single quotes. It can also be a multi-line template wrapped inside backticks char `.
Almost all HTML syntax is valid template syntax. However, because an Angular template is part of an overall webpage, and not the entire page, you don't need to include elements such as <html> , <body> , or <base> , and can focus exclusively on the part of the page you are developing.
Use "\" at the end of each line.
myApp.directive('myDir', function() {
return {
restrict: 'E',
template: '<div>\
|Hello,\
|{{test}}!\
|</div>'
};
Here's you Fiddle
You can simply use graves instead of single quotes
myApp.directive('myDir', function() {
return {
restrict: 'E',
template: `<div>
Hello,
{{test}}!
</div>`
};
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With