W dyrektywie chcę sprawdzić, czy element ma atrybut, zanim wykonam jakąś funkcję na nim. Ale nie widzę niczego stworzonego dla tego w jqLite docs.Odpowiednik AngularJS dla hasAttribute()?
np. :
.directive('noReadonly', function() {
return {
link: function($scope, $element, $attr, ctrl) {
$element.on('focus', function() {
if ($element.hasAttribute('readonly'))
$element.removeAttr('readonly');
});
},
}
})
'if (angular.isDefined ($ attr.readonly)) {...}' – Blackhole