我有一个指令<some-directive ver="val"></some-directive>
,它根据ver值返回带有动态句子的templateUrl
。我一直在尝试添加换行值,以便在嵌入到模板中时文本显示为两行,但\r
和\n
仅添加空格但不添加新行。
directive('someDirective', function(){
return {
restrict: 'E',
scope: true,
link: function (scope, element, attrs) {
//based on scope or attrs customize the first reply
var type=attrs.ver;
switch(type) {
case 'val1':
scope.lm = {
eng: 'This is my sentence that needs a break in the middle.',
cha: 'This is another sentence that needs a break in the middle.'
};
break;
case 'val2':
scope.lm = {
eng: 'This is my sentence that needs a break in the middle.',
cha: 'This is another sentence that needs a break in the middle.'
};
break;
default:
scope.lm = {
eng: 'This is my sentence that needs a break in the middle.',
cha: 'This is another sentence that needs a break in the middle.'
};
}
},
templateUrl : 'content/excerpts/some-template.html'
}
});
感谢任何帮助。
谢谢 AJG