Showing posts with label Angular2. Show all posts
Showing posts with label Angular2. Show all posts

Thursday, November 16, 2017

Angular Scroll-to-top component

I've recently created a small component providing a scroll-to-top functionality for any Angular 4 app. You can add it to your project and style it according to your needs.
The component provides 2 API attributes:

scrollOffset:

The amount of page scroll offset (from the top) in pixels after witch the component is shown. Default value is 0.

scrollDuration:

The scroll animation duration (ms). Default value is 500.


Code is available on Github.

Demo:


Saturday, October 7, 2017

PrimeNG Datatable Sticky Header

A directive providing sticky mode for PrimeNG data table.

I've recently got a request to have a PrimeNG datatable scrolled with the page but have the data table header stick to the top of the page while scrolling. As this feature is not available out of the box with the PrimeNG data table component, I've written a dedicated directive for it.

The directive sets the PrimeNG data table header to sticky mode when scrolling the page. This prevents the header from scrolling with the table thus keeping the user in context and allows data sorting even when scrolled.

Code is available on Github.

Demo:

Saturday, November 19, 2016

Angular 2 Component Loader

While developing complex Angular 2 applications, many times we encounter multiple page components, each loading its own data. Instead of blocking the entire screen with a loading message until all the data is loaded, its better to implement this behavior in the component level. This way, each component blocks itself until its own data is loaded, allowing the user to interact with other components during that time.

To achieve this behavior, I've created an attribute directive that can be attached to any component. It has 2 attributes: 

  1. The "loading" flag that should be set to true while data is loafing and false once data is loaded. This attribute is mandatory.
  2. An optional loading message that replaces the default "Loading..." message.
Note: Since the "loading" directive needs to cover the entire component, its css layout is set to "absolute". That means that the DIV element the directive is attached to must have its layout set to "relative".

See the demo below. The code can be viewed on Github.





Saturday, October 22, 2016

Angular 2 Checkbox Tree with Partial Selection

While working on a new Angular 2 project, we needed a checkbox tree that supports partial selection when only some children nodes are selected.
As we've been using the open source PrimeNG UI components library, it was simple enough to add check-boxes to the PrimeNG tree component using its build-in template support.
The more complicated task was to add the recursive logic required for setting parent selection on each node selection change.
Feel free to explore the demo, fork the source code on Github and use it for your own projects.





About Me

My photo
I've been developing Internet and rich-media application for 15 years. In my work I emphasis usability and best user experience as well as sleek design. My main expertise are JavaScript, Flex and Flash.

Followers