Home /Archive by Category "AngularJs"

AngularJS Custom Directives

Custom directives are used in AngularJS to extend the functionality of HTML. Custom directives are defined using “directive” function. A custom directive simply replaces the element for which it is activated. AngularJS application during bootstrap finds the matching elements and do one time activity using its compile() method of the custom directive then process the … Continue reading

AngularJS Services

AngularJS supports the concepts of “Seperation of Concerns” using services architecture. Services are javascript functions and are responsible to do a specific tasks only. This makes them an individual entity which is maintainable and testable. Controllers, filters can call them as on requirement basis. Services are normally injected using dependency injection mechanism of AngularJS. AngularJS … Continue reading

AngularJS Scopes

Scope is a special javascript object which plays the role of joining controller with the views. Scope contains the model data. In controllers, model data is accessed via $scope object. Following are the important points to be considered in above example. $scope is passed as first argument to controller during its contructor defintion. $scope.message and … Continue reading

AngularJS Views

AngularJS supports Single Page Application via multiple views on a single page. To do this AngularJS has provided ng-view and ng-template directives and $routeProvider services. ng-view ng-view tag simply creates a place holder where a corresponding view (html or ng-template view) can be placed based on the configuration. Usage Define a div with ng-view within … Continue reading

AngularJS – Ajax

AngularJS provides $http control which works as a service to read data from the server. The server makes a database call to get the desired records. AngularJS needs data in JSON format. Once the data is ready, $http can be used to get the data from server in the following manner:  

AngularJS Includes

HTML does not support embedding html pages within html page. To achieve this functionality following ways are used: Using Ajax – Make a server call to get the corresponding html page and set it in innerHTML of html control. Using Server Side Includes – JSP, PHP and other web side server technologies can include html … Continue reading

AngularJS Forms

AngularJS enriches form filling and validation. We can use ng-click to handle AngularJS click on button and use $dirty and $invalid flags to do the validations in seemless way. Use novalidate with a form declaration to disable any browser specific validation. Forms controls makes heavy use of Angular events. Let’s have a quick look on … Continue reading

AngularJS Modules

AngularJS supports modular approach. Modules are used to seperate logics say services, controllers, application etc. and keep the code clean. We define modules in seperate js files and name them as per the module.js file. In this example we’re going to create two modules. Application Module – used to initialize an application with controller(s). Controller … Continue reading