AngularJS – Image “onload” event

Here’s a re-usable directive in the style of angular’s inbuilt event handling directives: angular.module(‘sbLoad’, []) .directive(‘sbLoad’, [‘$parse’, function ($parse) { return { restrict: ‘A’, link: function (scope, elem, attrs) { var fn = $parse(attrs.sbLoad); elem.on(‘load’, function (event) { scope.$apply(function() { fn(scope, { $event: event }); }); }); } }; }]); When the img load event … Read more

How to select an element by classname using jqLite?

Essentially, and as-noted by @kevin-b: // find(‘#id’) angular.element(document.querySelector(‘#id’)) //find(‘.classname’), assumes you already have the starting elem to search from angular.element(elem.querySelector(‘.classname’)) Note: If you’re looking to do this from your controllers you may want to have a look at the “Using Controllers Correctly” section in the developers guide and refactor your presentation logic into appropriate directives … Read more