我想在Angular 2应用程序的输入标记中定义一个局部变量:
input(#sometext)
button((click)="addTechnology(sometext.value)") Add
我期待的输出是:
<input #sometext/>
<button (click)="addTechnology(sometext.value)">Add</button>
然而实际输出是(注意额外的="#sometext"
):
<input #sometext="#sometext"/>
<button (click)="addTechnology(sometext.value)">Add</button>
这样,Angular 2引发了以下错误,很可能是由于="#sometext"
:
Cannot find directive with exportAs = '#sometext'
Error: Cannot find directive with exportAs = '#sometext'
at new BaseException (https://code.angularjs.org/2.0.0-alpha.28/angular2.dev.js:7248:25)
at _findDirectiveIndexByExportAs (https://code.angularjs.org/2.0.0-alpha.28/angular2.dev.js:12454:13)
at https://code.angularjs.org/2.0.0-alpha.28/angular2.dev.js:12435:22
at Map.forEach (native)
at Function.execute.MapWrapper.forEach (https://code.angularjs.org/2.0.0-alpha.28/angular2.dev.js:7614:15)
at createDirectiveVariableBindings (https://code.angularjs.org/2.0.0-alpha.28/angular2.dev.js:12434:16)
at _createProtoElementInjector (https://code.angularjs.org/2.0.0-alpha.28/angular2.dev.js:12414:39)
at _createElementBinders (https://code.angularjs.org/2.0.0-alpha.28/angular2.dev.js:12391:34)
at _createAppProtoView (https://code.angularjs.org/2.0.0-alpha.28/angular2.dev.js:12331:5)
at https://code.angularjs.org/2.0.0-alpha.28/angular2.dev.js:12641:32
您是否知道有任何方法可以阻止Jade使用附加="#sometext"
完成属性?
答案 0 :(得分:8)
最后,它就像在Jade模板的开头使用doctype html
一样简单。我在主要布局中有它,但似乎包含的文件也需要它。