html - angularj js:html模板插入:每次插入修改属性值
问题描述
你好堆栈溢出社区!这是我的代码的迷你版。在这个例子中,我试图在 index.html 的每个 div 中插入我的模板,并在每次插入时更改它的 id。+ 为什么 h1 元素会消失?
<div id= "simpleSearchType OR advancedSearchType OR expertSearchType" >
this is the div to be inserted
</div >
任何帮助将不胜感激,谢谢。
解决方案
一个更简单的方法是使用ng-if
指令。
您可以searchType
在控制器中设置变量,并通过将 div 挂接到ng-if
.
推荐阅读
- linear-gradients - 如何在 Theme-ui 中使用渐变值?
- r - 为什么这个循环只正确读取第一个 txt 文件?
- asp.net - 从 ASP.NET 框架整体使用 Blazor 服务器端
- python - /gym/ninja/ninja() 的 TypeError 得到了一个意外的关键字参数
- sql - 如何引用 sqlite_master 的字段?
- java - 自定义程序 - IndexOutOfBoundsException
- python - request.get(url) 仅返回正文为空的标头信息
- python - 如何获取外键字段
- authentication - 如何在 Laravel 中为类似请求制作全局策略/中间件/门
- docker - Docker compose 容器通信