我正在处理混合angularjs和thymeleaf的应用程序中的问题。我想在百科全书中构建一个模板,允许我使用变量来指定要使用的角度属性指令。
似乎百里香叶不允许将变量用作属性。我尝试过以下方法:
<div th:attr="${portlet.attrDirective}">
....
</div>
没用?
<div th:inline="text">
<div [[${portlet.attrDirective}]]>
...
</div>
</div>
也没用?
我做错了吗?
他们portlet.attrDirective
有null
的可能性。
答案 0 :(得分:0)
我最终使用以下代码完成了工作:
<div th:attr="${portlet.attrDirective == null} ? nodirective : ${portlet.attrDirective}=${portlet.attrDirective}">
...
</div>
有没有人有更易读的解决方案?