O'Reilly logo

AngularJS Directives by Alex Vanston

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Events

When we first started this chapter, we said that we wanted to be able to hook into specific events. Masonry itself only provides two events, one when everything is laid out and one when an item is removed. Instead of Masonry events then, we'll create our own, starting with one for when it's first initialized, and another that fires anytime there's an update. Per usual, let's go ahead and write our unit tests first and then we'll update the directive code to satisfy them:

describe('Events', function () { var initEvent = 'masonry-initialized' , updateEvent = 'masonry-updated'; it('should not fire ' + initEvent + ' event when initialized with no elements', function () { var $parScope = $rootScope.$new(); var initialized = false; $parScope.$on(initEvent, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required