Articles with tag "Angular2"

Angular 2: Lazy-loading images using bLazy.js

I recently had the need to integrate bLazy in an Angular 2 project. This is a pure Javascript library so the integration was straightforward but it does have a few drawbacks to be aware of, especially due to the way Angular renders elements. The trick was wrapping bLazy initialization inside a setTimeout() which seems to be the only way for bLazy to properly set itself up. Here’s the code: Read more...

Angular 2: Structural directive for responsive conditional output using a CSS media query

Media queries are useful to adapt the way elements on a page are displayed, or even show/hide elements based on the viewport size. When working with Angular 2, there might be times where you not only want to conditionally show or hide an element depending on the viewport size, but you also need to make sure that your component does not even get instantiated when the app is run on a mobile or desktop. Read more...