Skip to main content

Posts

Showing posts from October, 2014

$rootScope using AngularJS Example

$rootScope               A $rootScope angular directive is using to support a global accessing for variables and function in a module. Angular $rootScope is live of scope object from the module.             $rootScope declare any one controller it will allow to accessing all controller no any restriction for implement. Will include the $rootScope directive from the controller library loader time. Sample $rootScope Declaration  var app = angular.module('rootModule',[]); app.controller('firstController',['$scope','$rootScope',function($scope, $rootScope){     console.log('first');     }]); Program Example Html: <div ng-app="rootModule">     <div ng-controller="firstController">         Click count : {{count}}          <input type="button" value="click" ng-click="countCal()" />     </div>     <div ng-controller="se

How to use $watch in angularJS

$watch in angularJS            watch method is listening component, what your mention to $watch expression name. If your mention of ng-model, this model have any reaction happen from your ng-model like your declared text type this ng-model happen key press or key type means that time this $watch method take every single action from corresponding ng-model. This action take and do it your new functionality of every single action process.         $watch method main purpose to happen every single action made to logic needed to apply from that location. Like key up and down function logic validation apply logic from here.       Example for your need to apply not allow space bar from your email id field that logic problem is need to apply for $watch method. $watch(watchExpression, listener, [objectEquality]); watchExpression - This is for reference to ng-model name declaration  listener - Listener is make function when it action happen that time to trigger for

Radio Button Selection using AngularJS

How to use radio button in angularJS    Radio button selection is apply to angular ng-click event method, this method passing param is $event Object. This $event  Object have corresponding radio button properties will return.   Radio Button angular properties  ngModel string It's to angular refer the bind properties  value string To get value or set value from the radio button  name string Property name of the form radio button. ngChange string To make event from the radio button ngValue string Angular expression value  Radio Button Example : HTML: <div ng-app="radiobtn">     <div ng-controller="radioController">         Select your favourite food <br/>         <input type="radio" name="fav" ng-model="fav_food" value="curd rice" ng-click="getFood($event)" />curd rice<br/>             <input type="radio" name="fav" ng-