html - HTML element with # to pug-template
问题描述
I've got a piece of code with 2 angular material radio buttons. Both of them have the #attribute/element (I'm not certain what it's called) within them. How can I convert them into pug so that the attribute/element with the # works? Here is sample code which has the #attribute/element in it that I'd like to make work in pug:
<mat-radio-button #firstRadio name="selection" value="one" (change)="aMethodCall();" color="primary" [checked]="oneSelected"> ...
</mat-radio-button>
<mat-radio-button #secondRadio name="selection" value="two" (change)="aMethodCall();" color="primary" [checked]= "!oneSelected"> ...
</mat-radio-button>
I've tried to turn it to pug:
mat-radio-button( #firstRadio, name="selection", value="one", (change)="aMethodCall()", color="primary", [checked]="oneSelected") ...
mat-radio-button( #secondRadio, name="selection", value="two", (change)="aMethodCall()", color="primary", [checked]="!oneSelected") ...
But the #elements are not registering in pug. Any help with the syntax to get them to work is appreciated. Ps. if you know the name of the #element I'd like to know it. Thanks.
解决方案
To answer my own question: getting the html with the # id tag to work 100% on pug, I used the html2jade which Sergi Nadal suggested. The resulting pug is then:
mat-radio-button(#firstradio='', name='selection', value='one', (change)='aMethodCall();', color='primary', [checked]='oneSelected')
| ...
mat-radio-button(#secondradio='', name='selection', value='two', (change)='aMethodCall();', color='primary', [checked]='!oneSelected')
| ...
So to bypass the # from working as a interpolation marker in pug, I can put it as an attribute with an empty value into the pug template to get it working.
推荐阅读
- qt - 运行脚本时不显示 Qt 按钮
- spring-data-elasticsearch - 无法使用 Spring Data ElasticSearch Repository 计算嵌套属性内具有特定值字段的实体的出现次数
- python - 熊猫平行适用于考拉(pyspark)
- c# - C# Web 应用程序 - 浏览器不向拨号器发送 # 符号
- python - 命令“python setup.py egg_info”失败,错误代码 1 在 /tmp/pip-build-eutop9/docal-tkinter/
- git - git checkout 获取 ASCII 文件而不是二进制文件
- font-awesome - 不再显示字体真棒图标 (2020)
- php - 是否可以复制/粘贴 xampp 文件夹并使其在另一台计算机上工作?
- azure-devops - 基于触发器的不同代理池或对同一 Azure Pipeline 的需求
- assembly - 为什么使用 AVX ymm(m256) 指令比 xmm(m128) 慢约 4 倍