我在Angular2 rc 1中有一个模板,我需要在其中显示来自不同语言的一大块代码.那个语言有{{在其中.
import {Component, Input} from '@angular/core';
@Component({
selector: 'blue-box',
template: `
<div class="blue-box">
<div class="blue-box-title">{{boxTitle}}</div>
{{define "bob"}}This is the template bob{{end}}
<span>
<ng-content></ng-content>
</span>
</div>
`,
styleUrls: ['../css/blue-box.css'],
})
export class BlueBox {
@Input() boxTitle: string;
constructor() {
}
}
Run Code Online (Sandbox Code Playgroud)
如何让模板处理器将{{作为文字字符串而不是模板表达式的开头?问题出现在{{define"bob"}},我需要一个文字{{.
浏览器(chrome)控制台上的错误是:
EXCEPTION: Template parse errors:
Parser Error: Unexpected token 'bob' at column 8 in [
{{define "bob"}}This is the template bob{{end}}
] in BlueBox@2:49 ("
<div class="blue-box">
<div class="blue-box-title">{{boxTitle}}</div>[ERROR ->]
{{define "bob"}}This is the template bob{{end}}
<span> …Run Code Online (Sandbox Code Playgroud) angular ×1