Skip to main content

Posts

Showing posts from March, 2015

Search from list using angularjs

        An array have list of n number items is available in a array object. This object will listout using ng-repeat to list items. We take sample example for counties, we have list item show in the DOM pages. This item is have all counties, i want specific country is available from the list to check using angular filter concept. Filter is apply to search a specific country from the list.         This fetch ng-repeat filter concept using angular, this is fetch a corresponding scope of array object only. This happen DOM itself, no need to write logic from. HTML:    <div ng-app="searchApp"> <div ng-controller="searchCtrl">     Search : <input type="text" ng-model="search"/>     <ul ng-repeat="country in countries | filter:search">         <li>{{country.name}}</li>     </ul>     <p ng-show="(countries | filter:search).length==0"> No search result</p> </div>

Angular undefined

An angularjs variable define is have a assign any value or not to find a default properties is angular.isUndefined. I will give a sample logic is undefined checking logic. HTML Code <div ng-app="testApp">     <div ng-controller="TestCtrl">         Variable $scope.name is undefined ==>> {{value1}}         <br/>        Variable $scope.place is undefined ==>> {{value2}}     </div> </div>   AngularJS  var app = angular.module('testApp',[]); app.controller('TestCtrl', function($scope){     $scope.name;     $scope.value1 = angular.isUndefined($scope.name);     $scope.place = "chennai";     $scope.value2 = angular.isUndefined($scope.place); }); Result: Demo