Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Preventing Jade from adding an assignment clause in an HTML element

I want to define a local variable in an input tag for an Angular 2 application:

input(#sometext)
button((click)="addTechnology(sometext.value)") Add

The output that I am expecting is:

<input #sometext/>
<button (click)="addTechnology(sometext.value)">Add</button>

However the real output is (notice the additional ="#sometext"):

<input #sometext="#sometext"/>
<button (click)="addTechnology(sometext.value)">Add</button>

This way, Angular 2 throws the following error, very likely due to that ="#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

Do you know any way of preventing Jade from completing the attribute with the additional ="#sometext"?

like image 970
codependent Avatar asked Aug 05 '15 12:08

codependent


1 Answers

In the end it was as simple as using doctype html at the beginning of the Jade template. I had it in the main layout but it seems that the included files also need it.

like image 124
codependent Avatar answered Oct 16 '22 20:10

codependent