Passing Data Between Controllers in Angular JS

We can share data between two or more controllers using service or factory. Example: First, I am creating a product service. myApp.service(‘productService’, function() { var product = [], addProduct, getProductList, removeProduct; addProduct = function(obj) { product.push(obj); }; getProductList = function(){ return product; }; removeProduct = function(id { product.splice(id, 1); }; return { addProduct: addProduct, removeProduct: […]

Continue reading


Change curly braces to other symbols in AngularJS

In Angular JS, We can change delimiter curly braces to other symbol. You can change start and end interpolation symbol using interpolateProvider service. you can change {{var}} to [[var]] or any symbols. Example: angular.module(‘app’, []) .config(function($interpolateProvider){ $interpolateProvider.startSymbol(‘[[‘).endSymbol(‘]]’); }); or angular.module(‘app’, []) .config(function($interpolateProvider){ $interpolateProvider.startSymbol(‘//’).endSymbol(‘//’); });   And in your template before: {{ hello }}   after: [[ […]

Continue reading


Angularjs Directive – Accept Number Only

Angularjs Directive Accept Number Only A angularjs directive which allows only numbers to be typed into a text box .   FEATURES Accepts only numbers. Accepts negative number. Accepts floating Number DIRECTIVE CODE Add this directive in your application. app.directive(‘nksOnlyNumber’, function () { return { restrict: ‘EA’, require: ‘ngModel’, link: function (scope, element, attrs, ngModel) […]

Continue reading


Understanding of ng-repeat-start and ng-repeat-end – Repeating over multiple elements

First we will see problem with  ng-repeat in some case. One issue with ng-repeat : How to create this table structure with given  list ?? <table>      <tbody>         <tr> <td>Nitish</td> </tr> <tr> <td>26</td> <td>Male</td> </tr> <tr> <td>Ranveer</td> </tr> <tr> <td>24</td> <td>Male</td> </tr> </tbody> </table> With this json. $scope.list = [{name: […]

Continue reading


Angular Lazy One-time binding support {{ ::value }}

Expressions that start with `::` will be binded once. The rule that binding follows is that the binding will take the first not-undefined value at the end of a $digest cycle. Watchers from $watch, $watchCollection and $watchGroup will automatically stop watching when the expression(s) are bind-once and fulfill. Watchers from text and attributes interpolations will […]

Continue reading