在一個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