| by Gagandeep Singh | No comments

$apply() function and digest loop in AngularJS

In AngularJS we have a function $apply() which is a part of $scope object. The $apply() function accepts a function as its parameter. This function which is passed to the $apply() contains the code where the changes are being done to the models which are used in our AngularJS application. For AngularJS application to know […]

Read More
| by Gagandeep Singh | No comments

$watch – Watchers in AngularJs

Watchers are used in AngularJs to check if the value of a model has been changed; if yes then take some appropriate action. To check the value of the model we use the $watch() method provided inside the $scope object. angular.module(‘MyFirstModule’,[]).controller(‘MyFirstController’,function($scope){ $scope.salary=’25000′; $scope.$watch(‘salary’,function(newSalary,oldSalary){ console.log(“There has been change in your salary”); } }); The first parameter […]

Read More
| by Gagandeep Singh | No comments

Dependency Injection in Controllers in case of Minification

Dependency Injection means providing additional parameters to the Controller function on which our controller code may depend. For example, in the below code, we are passing $http as an additional parameter in our controller function which might be used inside the controller function. angular.module(‘MyFirstModule’,[]).controller(‘MyFirstController’,function($scope,$http){ // controller code } ); The problem arises if we minify […]

Read More
| by Gagandeep Singh | No comments

Creating Our First Module in AngularJs

To build a module we make use of angular.module() function. This function accepts two parameters; first is the name which we want to give to our module and second is an array which contains the name of additional modules on which our module is dependent. If the module is not dependent on any other module, […]

Read More
| by Gagandeep Singh | No comments

Showing HTML content in AngularJS expressions

AngularJS will remove any HTML markup that you want to display on the screen using an expression. For example. $scope.message=”Welcome to pixxstudios”; and expression is: {{message}} When Angular tries to execute this expression, it will remove any HTML markup it finds ( in this case and ) and will convert it to normal text. So […]

Read More