Skip to main content

Posts

Showing posts from August, 2014

How to use forEach in angularJS

forEach in angularJS           forEach is iterator of object collection convert to collection of array. An array into collection of iterator have two param value and key.  Value - a value of properties in a iterator collection. key   - properties of value  Syntax :        angular.forEach(obj, iterator, [context]) Example : <div ng-app="modeleach">     <div ng-controller="controllereach">         For each array value {{temp}}     </div> </div> JavaScript : var app = angular.module("modeleach",[]); app.controller("controllereach",['$scope',function($scope){     var techArray = {name:"rajesh", state:"tamilnadu", country:"india" };     var val = [];          angular.forEach(techArray, function(value, key) {         this.push(value);     }, val);     console.log("List of item ==> "+ val);     $scope.temp = val; }]);

How to use ng-Show in directive

How to use ng-Show in directive ?      An ng-Show directive is a block or session of DOM presenting or hide the functional ng-Show attribute value base. If ng-Show directive value have false means that DOM block is not appear, The directive value have true means That DOM block is appear.  Example HTML:            <div ng-app="ShowModule">     <div ng-controller="ShowContoller">         <div ng-show="flag" class="myStyle">             welcome to the India         </div>         <button ng-click="show()">Show</button>         <button ng-click="hide()">Hide</button>     </div> </div> Javascript : var app = angular.module("ShowModule",[]); app.controller("ShowContoller", function($scope){     $scope.flag = false;     $scope.show = function() {         $scope.flag = true;         }     $scope.hide =

How to array value or Array Object show in table using angularJS

How to array value or Array Object show in table using angularJS ?          An array object or array value view into  a template using ng-repeat directive. This directive will take key and value to presenting in a template. Sample array value :   $scope.rankList = [   {name:'John', age:25, gender:'boy', rankHolder:5},   {name:'Jessie', age:30, gender:'girl', rankHolder:4},   {name:'Johanna', age:28, gender:'girl', rankHolder:6},   {name:'Joy', age:15, gender:'girl', rankHolder:1},   {name:'Mary', age:28, gender:'girl', rankHolder:2},   {name:'Peter', age:95, gender:'boy', rankHolder:3}    ]; Example: <div ng-app="repeatModule">     <div ng-controller="repeatController">      <table border="1">          <tr>              <th>S.No</th>              <th>Name</th>              <th>Age</th&g