我在 angular 指令中使用了多个 datepicker,它给了我一个错误 Uncaught Missing instance data for this datepicker因为如果我删除了一个 li 那么它不会在指令中设置 id。
指令.js
app.directive('datepicker', function () {
  return {
    link: function($scope, element, attrs) {
    setTimeout(function() {
            $("#"+attrs.id).live('focus',function(){
                console.log(attrs.id);
             });
     });
   }
}
索引.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?