เพื่อตั้งโฟกัสที่ text input ในรายการ ลองโค้ดด้านล่าง:
newApp.directive('focus', function () {
return function (scope, element, attrs) {
attrs.$observe('focus', function (newValue) {
newValue === 'true' && element[0].focus();
});
};
});
HTML:
<input type="text" ng-model="cues[$index].text" focus="{{cue.isNewest}}" class="input-xlarge" />{{cue.isNewest}}