Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我希望将带有 ng-include="'abc.html'" 的 div 包含到来自 javascript 的 HTML 中。请让我知道如何添加它,因为我面临的问题是在“''”中获取 ng-include 值。
有多种方法可以有条件地在角度中包含部分。这里有几个方法。
使用 ng-show / ng-hide 显示或隐藏使用 ng-include 包含的元素。这只实现了显示或隐藏,并没有将其从 DOM 中取出。
在 ng-include div 上放置一个 ng-switch。更改开关观察到的变量,并使用 ng-switch 值切换包含或不包含。
ng-include 本身接受一个变量。如果您不设置该变量或将其设置为 null,那么在您将变量的值更改为指向您的部分位置之前,它不会显示任何内容。