2017-05-19 14 views
1

私は、ブートストラップと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> 

答えて

0
data-ng-href="{{'go' + $index}}" 
data-ng-id="{{'go' + $index}}" 
1

あなたはangularjsに引用マークの中の文字列と変数を組み合わせたい場合は、JavaScriptで有効な式のようにそれを行う必要があります。「文字列」+ $変数 <div data-ng-id="'go'+$index" class="panel-collapse collapse">

関連する問題