angularUtils
A place where I will collect useful re-usable Angular components that I make
Top Related Projects
Deliver web apps with confidence 🚀
CLI tool for Angular
Reactive State for Angular
The internationalization (i18n) library for Angular
Material design for AngularJS
Angular UI Component Library based on Ant Design
Quick Overview
AngularUtils is a collection of utility modules and services for AngularJS applications. It provides various reusable components and helpers to simplify common tasks in Angular development, such as pagination, data table management, and directive communication.
Pros
- Offers a wide range of utility modules for different purposes
- Well-documented and easy to integrate into existing AngularJS projects
- Actively maintained with regular updates and bug fixes
- Modular structure allows developers to use only the components they need
Cons
- Primarily focused on AngularJS (1.x), which is now considered legacy
- May require additional configuration or adaptation for use with newer Angular versions
- Some modules might have limited customization options
- Dependency on AngularJS limits its use in modern web development projects
Code Examples
- Pagination directive usage:
<div ng-controller="MyController">
<ul>
<li dir-paginate="item in items | itemsPerPage: 10">{{ item }}</li>
</ul>
<dir-pagination-controls></dir-pagination-controls>
</div>
- Data table sorting:
<table>
<thead>
<tr>
<th sort-default="true" dir-paginate="th in tableHeaders | orderBy:sortType:sortReverse">
<a href="" ng-click="sortType = th.sortKey; sortReverse = !sortReverse">
{{th.label}}
<span ng-show="sortType === th.sortKey && !sortReverse" class="fa fa-caret-down"></span>
<span ng-show="sortType === th.sortKey && sortReverse" class="fa fa-caret-up"></span>
</a>
</th>
</tr>
</thead>
<tbody>
<tr dir-paginate="row in tableData | orderBy:sortType:sortReverse | itemsPerPage: 10">
<td ng-repeat="cell in row">{{cell}}</td>
</tr>
</tbody>
</table>
- Disqus comment integration:
<dir-disqus config="disqusConfig"></dir-disqus>
Getting Started
To use AngularUtils in your AngularJS project:
-
Install the package via npm:
npm install angular-utils
-
Include the desired module in your Angular app:
angular.module('myApp', ['angularUtils.directives.dirPagination']);
-
Use the utility in your HTML templates or controllers as shown in the code examples above.
Competitor Comparisons
Deliver web apps with confidence 🚀
Pros of Angular
- Official framework with extensive documentation and community support
- Comprehensive solution for building large-scale applications
- Regular updates and long-term support from Google
Cons of Angular
- Steeper learning curve for beginners
- Larger bundle size and potentially slower initial load times
- More opinionated structure, which may limit flexibility in some cases
Code Comparison
AngularUtils (Directive example):
angular.module('myApp').directive('myDirective', function() {
return {
restrict: 'A',
link: function(scope, element, attrs) {
// Directive logic here
}
};
});
Angular (Component example):
@Component({
selector: 'app-my-component',
template: '<div>{{ message }}</div>'
})
export class MyComponent {
message = 'Hello, Angular!';
}
Summary
AngularUtils is a collection of utilities for AngularJS (Angular 1.x), while Angular is the modern, component-based framework for building web applications. Angular offers a more robust and scalable solution but comes with a steeper learning curve. AngularUtils provides specific utilities for AngularJS projects, which may be useful for maintaining legacy applications. However, for new projects, Angular is generally recommended due to its ongoing development and support.
CLI tool for Angular
Pros of angular-cli
- Official Angular tool with extensive CLI capabilities for project scaffolding, development, and build processes
- Regularly updated and maintained by the Angular team, ensuring compatibility with the latest Angular versions
- Provides a standardized project structure and best practices for Angular development
Cons of angular-cli
- Steeper learning curve for beginners due to its comprehensive feature set
- Less flexibility for customizing project structure compared to smaller utility libraries
- Larger package size and potential overhead for simpler projects
Code Comparison
angularUtils:
angular.module('myApp', ['angularUtils.directives.dirPagination'])
.controller('MyController', function($scope) {
$scope.currentPage = 1;
$scope.pageSize = 10;
});
angular-cli:
ng new my-angular-project
cd my-angular-project
ng generate component my-component
ng serve
Summary
angularUtils is a collection of utilities and directives for AngularJS, offering specific solutions for common tasks. It's lightweight and easy to integrate into existing projects. On the other hand, angular-cli is a comprehensive tool for Angular (2+) development, providing a complete ecosystem for project creation, development, and deployment. While angular-cli offers more features and standardization, it may be overkill for smaller projects or those requiring more customization.
Reactive State for Angular
Pros of ngrx/platform
- Comprehensive state management solution for Angular applications
- Implements Redux pattern for predictable state changes
- Extensive ecosystem with additional libraries and tools
Cons of ngrx/platform
- Steeper learning curve for developers new to Redux concepts
- Can introduce complexity for smaller applications
- Requires more boilerplate code compared to simpler solutions
Code Comparison
ngrx/platform:
import { createAction, props } from '@ngrx/store';
export const increment = createAction('[Counter] Increment');
export const decrement = createAction('[Counter] Decrement');
export const reset = createAction('[Counter] Reset');
angularUtils:
import { Directive, ElementRef, Input } from '@angular/core';
@Directive({
selector: '[myDirective]'
})
export class MyDirective {
@Input() myInput: string;
constructor(private el: ElementRef) {}
}
Key Differences
- ngrx/platform focuses on state management, while angularUtils provides various utility directives and services
- angularUtils offers smaller, more focused solutions for specific Angular tasks
- ngrx/platform is better suited for large-scale applications with complex state requirements
- angularUtils is more approachable for developers looking for quick, standalone solutions
Use Cases
- Choose ngrx/platform for enterprise-level applications with complex state management needs
- Opt for angularUtils when looking for specific utility functions or directives to enhance Angular development
The internationalization (i18n) library for Angular
Pros of ngx-translate/core
- Focused specifically on internationalization (i18n) for Angular applications
- Actively maintained with regular updates and a large community
- Supports dynamic translations and language switching at runtime
Cons of ngx-translate/core
- Limited to translation functionality, unlike angularUtils which offers various utilities
- May require additional setup and configuration compared to angularUtils
- Potential performance overhead for large-scale applications with many translations
Code Comparison
ngx-translate/core:
import { TranslateService } from '@ngx-translate/core';
constructor(private translate: TranslateService) {
translate.setDefaultLang('en');
translate.use('fr');
}
angularUtils:
import { pagination } from 'angular-utils-pagination';
angular.module('myApp', [pagination])
.controller('MyController', function($scope) {
$scope.currentPage = 1;
$scope.pageSize = 10;
});
The code snippets demonstrate the different focus areas of the two libraries. ngx-translate/core is centered around translation services, while angularUtils provides various utilities like pagination.
Material design for AngularJS
Pros of Material
- Comprehensive UI component library with Material Design aesthetics
- Official Angular team support and regular updates
- Extensive documentation and community resources
Cons of Material
- Larger bundle size due to comprehensive feature set
- Opinionated design may require more customization for unique styles
- Steeper learning curve for full utilization of all components
Code Comparison
Material:
import { MatButtonModule } from '@angular/material/button';
@NgModule({
imports: [MatButtonModule],
// ...
})
export class AppModule { }
angularUtils:
import { dirPagination } from 'angular-utils-pagination';
angular.module('myApp', ['angularUtils.directives.dirPagination'])
.controller('MyController', function($scope) {
// ...
});
Summary
Material is a comprehensive UI library with official Angular support, offering a wide range of components and extensive documentation. However, it comes with a larger bundle size and a more opinionated design. angularUtils, on the other hand, provides specific utilities and directives for Angular, with a smaller footprint and more flexibility, but lacks the extensive component library and official support of Material.
Angular UI Component Library based on Ant Design
Pros of ng-zorro-antd
- Comprehensive UI component library with a wide range of pre-built components
- Active development and regular updates
- Extensive documentation and examples
Cons of ng-zorro-antd
- Larger bundle size due to the extensive component library
- Steeper learning curve for developers new to Ant Design principles
- Less flexibility for customization compared to individual utilities
Code Comparison
ng-zorro-antd:
import { NzButtonModule } from 'ng-zorro-antd/button';
@NgModule({
imports: [NzButtonModule],
// ...
})
export class AppModule { }
angularUtils:
import { dirPagination } from 'angular-utils-pagination';
angular.module('myApp', ['angularUtils.directives.dirPagination'])
.controller('MyController', function($scope) {
// ...
});
The code comparison shows that ng-zorro-antd uses a more modular approach with separate imports for each component, while angularUtils typically involves importing specific utilities or directives into an Angular module.
ng-zorro-antd provides a cohesive design system and a wide range of components, making it suitable for large-scale applications. angularUtils, on the other hand, offers individual utilities that can be easily integrated into existing projects without introducing a complete UI framework.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Angular Utilities
No longer maintained
(20/04/2017) - I am no longer actively maintaining this project. I no longer use AngularJS in my own projects and do not have the time to dedicate to maintiaining this project as well as my other active open source projects. Thank you for your understanding.
I am working on a large-scale AngularJS-based project and I'll be extracting any useful re-usable components that I make and putting them here.
I'm following the convention of the [Ng-Boilerplate] (https://github.com/ngbp/ngbp) project of bundling all relevant code together, so that you should be able to simply copy the directory of the component you want to use, and it will include unit tests and any other dependencies.
This code is made available under the MIT license, so feel free to use any of these is your projects. If you find any of them useful I'd be happy to get feedback!
Index of Utilities
Filters
- ordinalDate : Works like the built-in date filter, but will add the English ordinal suffix to the day.
- startsWith : Filter for strings which start with the search string.
Directives
- Disqus : Embed a Disqus comments widget in your app
- tagbox : A Twitter-style tag suggestion and auto-complete directive that can be added to any text input or textarea.
- uiBreadcrumbs : Auto-generated breadcrumbs for angular-ui-router using nested views.
- pagination : Magical automatic pagination for anything.
- terminalType : Terminal-like typing effect for DOM nodes containing text.
Services
- noise : A simple 1D interpolated noise generator.
License
MIT
Top Related Projects
Deliver web apps with confidence 🚀
CLI tool for Angular
Reactive State for Angular
The internationalization (i18n) library for Angular
Material design for AngularJS
Angular UI Component Library based on Ant Design
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot