EspañolDeutschFrançaisItalianoPortuguêsРусскийΕλληνικά日本語中文(简体)हिन्दी; हिंदीالعربية
设置为默认语言
PF 问题 - 论坛

如何在 AngularJS 中的 DIV 元素??

Quisiera saber como puedo crear un elemento DIV dinámicamente en Angular JS.

<table ng-controller="tableController">
   <tr ng-repeat="totaldivs en parametros">
      <td ng-repeat="divId en totaldivs">
 <!-- 
 quiero poner algo como esto
 <div id="dias_01"><span>DIV_01</span></div>
 -->
      </td>
   </tr>
</table>

En jQuery puedo hacerlo usando $('#IdOr.Class').html(param); pero ¿como lo hago en AngularJS?

Share on Facebook Tweet about this on Twitter Share on Google+ Pin on Pinterest Share on Reddit Share on VK Share on StumbleUpon Share on Tumblr Share on LinkedIn Email this to someone Print this page
portirca preguntó 我们的一日三餐 7 年
1 答案

Puedes hacer algo así:

<table ng-controller="tableController">
<tr ng-repeat="totaldivs en parametros">
<td ng-repeat="divId en totaldivs">
<div id="{{divId}}"><span>{{divContent}}</span></div>
</td>
</tr>
</table>

Ya estás dentro del bucle, por lo que el div se creará por cada td. Solo necesitas enlazar los valores a los divs.

Share on Facebook Tweet about this on Twitter Share on Google+ Pin on Pinterest Share on Reddit Share on VK Share on StumbleUpon Share on Tumblr Share on LinkedIn Email this to someone Print this page
arnelo 说的得 7 年