Skip to main content

Posts

Showing posts from January, 2016

Group by select ng-options in angularjs

An angularjs ng-options have iterate the array or object based the number of  item available from the component. This item normally we use ng-options for key and value  previous   example . Now our requirement is need to Group feature from the selection option. Group By - This is the component of group list item or value added from the option label. value.category group by value.name for (key, value) in data The above format is write a (<optgroup>) select option UI <optgroup label="mobile"><option value="0">Moto,MicroMax,HTC,Apple</option></optgroup>  HTML <div ng-app="Opt"> <div ng-controller="OptCtrl"> <span>Name :</span> <span>   <select ng-options="value.category group by value.name for (key, value) in data" ng-model="yourItem"> <option value="">-- Select Country --</option> </select> <br>

Why Angular 2.0?

Before accepting into added altercation about Angular 2.0 (which has an estimated absolution date of the end of 2015), let’s briefly accede the aesthetics abaft the new version. Angular 2.0 development was started to abode the afterward concerns: Mobile   The new Angular adaptation will be focused on the development of adaptable apps. The account is that it’s easier to handle the desktop aspect of things, already the challenges accompanying to adaptable (performance, amount time, etc.) accept been addressed. Modular   Various modules will be removed from Angular’s core, consistent in bigger performance. These will acquisition their way into Angular’s ever-growing ecosystem of modules, acceptation you’ll be able to aces and accept the locations you need. Modern  Angular 2.0 will ambition ES6 and “evergreen” avant-garde browsers (those automatically adapted to the latest version). Building for these browsers agency that assorted hacks and workarounds th

ng-options using Angularjs

     An ng-option is select directive will dynamically added data from the list of items. Array or object value will iterate one by one and bind the <option> tag value and label. ng-option is very useful for select tag implement. HTML : <div ng-app="Opt"> <div ng-controller="OptCtrl">     <span>Name :</span>     <span>     <select ng-options="country as country.name for country in countrys track by country.id" ng-model="yourCountry">        <option value="">-- Select Country --</option>     </select>     <br>     <span>Code :</span>     <select ng-options="code for code in codes" ng-model="yourCode">        <option value="">-- Select Code --</option>     </select>     </span> </div> </div> angular JS: var app = angular.module('Opt',[]); app.controller('OptCtrl', fu

AngularJs using $localStorage one time declaration

         An angularjs directive have a scope value from the declared controller. Suppose your need a global access meas using $rootScope declaration to access all controller from the application.            $localStorage is long time storage a browser data, It will reuse the data. This localStorage is declare into ngStorage.js library. HTML Code: <div ng-app="Loc"> <div ng-controller="LocCtrl"> <div ng-click="clickCount()"> Count : <span>{{count}}</span> </div> </div> </div> JS code: var app = angular.module("Loc",['ngStorage']); app.controller('LocCtrl', function($scope, $localStorage){   //One time local storage  logic  if(angular.isUndefined($localStorage.storeCount)){     console.log('Local storage data one time set');          $localStorage.storeCount = 0;  }   $scope.count = $localStorage.storeCount;        // Click Logic     $scope.clickCount = fu