角度ディレクティブで複数の日付ピッカーを使用しましたが、 1つのliを削除すると、ディレクティブにidが設定されないため、この日付ピッカーのインスタンスデータが見つかりませんというエラーが発生します。
directive.js
app.directive('datepicker', function () {
return {
link: function($scope, element, attrs) {
setTimeout(function() {
$("#"+attrs.id).live('focus',function(){
console.log(attrs.id);
});
});
}
}
index.html
<tr ng-repeat="payment in invoice.payment" id="payment">
<td>
<input class="payment_date" id="{{$index}}" placeholder="Payment Date" type="text" ng-model="payment.date" datepicker/>
<br />
</td>
</tr>
どうすればdirective.jsにIDを設定できますか?