EspañolDeutschFrançaisItalianoPortuguêsРусскийΕλληνικά日本語中文(简体)हिन्दी; हिंदीالعربية
تعيين اللغة الافتراضية
أسئلة PF - المنتدى

قم بإنشاء عنصر 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
بورتيركا سأل 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 السنوات