value and constant:-

Value and Constant are simple objects which are used to share data globally with in a module.

Value:-

It’s define globally. It’s not injected.

Ex var app= angular.module('myapp',[]);

app.value("companyname", "Infosys");

app.constant('address', { buildingno: '2', landmark: 'wipro circle',});

app.controller('HomeController',function($scope,companyname,address){

$scope.companyname=companyname;

$scope.landmark=address.landmark;

});

Constant :-

It define globally .I can be injected.It can store data in json format.

Factory:-http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/

results matching ""

    No results matching ""