指令定义中的多行模板

igo*_*gor 6 angularjs angularjs-directive

我正在尝试制作一个指令模板多行.这可能吗?

myApp.directive('myDir', function() {
return {
    restrict: 'E',        
    template: '<div>
                |Hello,
                |{{test}}!
                |</div>'
    };
});
Run Code Online (Sandbox Code Playgroud)

这是一个小提琴,看看我的意思.

Ami*_*ich 17

在每行末尾使用"\".

myApp.directive('myDir', function() {
return {
    restrict: 'E',        
    template: '<div>\
                |Hello,\
                |{{test}}!\
                |</div>'
};
Run Code Online (Sandbox Code Playgroud)

这是你小提琴