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