我在模板中有这个:
<div>{{String(element.elementId)}}</div>
但是我收到了这个错误:
TableBasicExample.html:6 ERROR TypeError: _co.String is not a function
at Object.eval [as updateRenderer] (TableBasicExample.html:6)
at Object.debugUpdateRenderer [as updateRenderer] (core.js:14727)
at checkAndUpdateView (core.js:13841)
at callViewAction (core.js:14187)
at execEmbeddedViewsAction (core.js:14145)
at checkAndUpdateView (core.js:13837)
at callViewAction (core.js:14187)
at execComponentViewsAction (core.js:14119)
at checkAndUpdateView (core.js:13842)
at callViewAction (core.js:14187)
我想要做的是在element.elementId
为空时显示字符串文字“null”,如果element.elementId
为undefined
则显示“未定义”,我该怎么做?< / p>
答案 0 :(得分:1)
尝试这个三元组:
<div>{{ element.elementId ? String(element.elementId) : "undefined or null"}}</div>
为什么你需要知道它是否为null vs undefined?它使检查稍微复杂化,但肯定可以完成。