Reputation: 34677
Does element.width()
not work anymore or am I wrong to assume that it gives you width of an element?
angular.module('app', []).directive('app', function() {
return {
restrict: 'E',
link: function(scope, element) {
console.log(element.width());
// => Error: element.width is not a function
},
};
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="app">
<app></app>
</div>
Upvotes: 4
Views: 3717
Reputation: 5458
from angularjs angular.element's docs:
If jQuery is available, angular.element is an alias for the jQuery function. If jQuery is not available, angular.element delegates to Angular's built-in subset of jQuery, called "jQuery lite" or "jqLite."
jqlite has a limited api, and it doesn't include .width() function
Upvotes: 7