在一个html表中,我有一个使用ng-repeat构造的行的列表。在这些行内我有一个单选按钮,它使用jquery来改变样式。风格是通过使用这个jQuery应用...我应该把这个jQuery内部的角度控制器?
<script>
$(document).ready(function() {
$('.i-checks').iCheck({
checkboxClass: 'icheckbox_square-green',
radioClass: 'iradio_square-green'
});
});
</script>
当我把在页面的代码,单选按钮造型不起作用。但是,如果我把代码中的表行中 - 它的工作...
<div ng-controller="supplierController" class="row">
<div class="col-lg-6 m-t-m">
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5>Price results </h5>
</div>
<div class="ibox-content">
<table class="table table-striped">
<thead>
<tr>
<th>Vendor</th>
<th>Details</th>
<th></th>
</tr>
</thead>
<tbody>
<tr ng-repeat="supplier in suppliers.prices">
<td>{{ supplier.supplier_name }}</td>
<td>£{{ supplier.price }}</td>
<td>
<div class="radio i-checks"><label> <input
type="radio" name="a"> <i>this</i></label>
<script>
$(document).ready(function() {
$('.i-checks').iCheck({
checkboxClass: 'icheckbox_square-green',
radioClass: 'iradio_square-green'
});
});
</script>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
这工作 - 但显然它的一个可怕的想法,因为jQuery是呈现每一行。所以我的问题是,这个代码放在哪里是最好的地方,所以它也可以工作?我应该把它放入控制器吗?
道歉,如果我不清楚,我是Angular的新手。
非常感谢
如果它与dom交互(在这种情况下,这是真的)它应该在一个指令。到目前为止,我看到的唯一例外是创建服务来处理对话或警报。 – 2015-01-26 22:39:41