...
Meet AngularJS!
Data Binding and Responding to Scope Changes
...
Dependency Injection
- Implicit dependency injection works fine until you minimize your code and then it falls apart. For production use, it is recommended to explicitly annotate injections with $inject.
Spreading route definitions among several modules
...
Directives
- While declaring an AngularJS directive, the naming convention followed is camelCase. For example, we would define the name of the directive as 'myDatePicker'. But when you actually use the directive in your HTML, it is the dash-separated version (my-date-picker).
- To make your directives and attributes HTML5 compliant, you can prefix all AngularJS attributes with "data-" or "x-". That is, "x-ng-show" or "data-date-picker", and AngularJS will treat it just like you wrote it like a normal HTML element.
Spreading route definitions among several modules
In a large scale web application, it is not uncommon to have dozens and dozens of different routes. While the $routeProvider service offers a very nice, fluent style API, route definitions can get quite verbose (especially when the resolve property is used). If we combine a large number of routes with the relative verboseness of each definition, we quickly end up maintaining a huge JavaScript file with several hundreds of lines of code! Worse yet, having all routes defined in one huge file means that this file must be modified quite frequently by all developers working on a project – a recipe for creating a bottlenecks and disastrous merge issues.
With AngularJS, we are not forced to define all the routes in one central file! If we take the approach of modularizing each functional area (has its own dedicated module), we can move routes linked to a certain part of an application to the corresponding module.
In the AngularJS module system, each and every module can have its associated config function, where we can inject $routeProvider service and define routes. For example: each of these submodules defines its own routes as follows:
...
issues.
With AngularJS, we are not forced to define all the routes in one central file! If we take the approach of modularizing each functional area (has its own dedicated module), we can move routes linked to a certain part of an application to the corresponding module.
In the AngularJS module system, each and every module can have its associated config function, where we can inject $routeProvider service and define routes. For example: each of these submodules defines its own routes as follows:
Code Block | ||||
---|---|---|---|---|
| ||||
angular.module('admin-projectsusers', []) .config(function ($routeProvider) { $routeProvider.when('/admin/users', {...}); $routeProvider.when('/admin/users/new', {...}); $routeProvider.when('/admin/users/:userId', {...}); }); angular.module('admin-projects', []) .config(function ($routeProvider) { $routeProvider.when('/admin-projects/users', 'admin-users']); |
Directives
...
{...});
$routeProvider.when('/admin/users/new', {...});
$routeProvider.when('/admin/users/:userId', {...});
});
angular.module('admin', ['admin-projects', 'admin-users']);
|
Pentaho Platform Integration
// TO DO