我尝试使用bootstrap和angularjs制作可折叠面板。我已成功接收到数据,但未能动态输入面板标题的“ href”和相关正文的“ id”。以下html演示了我如何尝试分配“ href和id”。
的HTML
<div class="panel-group" data-ng-repeat="Art in Articles" id="accordion">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" data-ng-href="go$index"><%-- here is my problem href in runtime not working --%>
{{Art.Art_Title}}
</a>
</h4>
</div>
<div data-ng-id="go$index" class="panel-collapse collapse"> <%-- same problem here with related id --%>
<img data-ng-src="{{Art.Art_Pic}}" style="margin: 20px; border: 4px solid #FFFFFF;
width: 140px; height: 100px; float: left;" />
<div class="panel-body" style="padding: 5px; margin: 5px; text-align: right; background-image: url('../App_Pic/bg03.jpg');">
{{Art.Art_Body}}
</div>
<button type="button" class="btn btn-primary btn-sm " style="margin-bottom: 10px">Read More ...</button>
</div>
</div>
</div>
最佳答案
data-ng-href="{{'go' + $index}}"
data-ng-id="{{'go' + $index}}"
关于javascript - 如何通过angularjs $ index分配href或id,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/44059531/