Thursday, 21 April 2016

Value in angular:

A value is nothing more than a simple injectable value. The value can be a string, number but also a function. Value differs from constant in that value can not be injected into configurations, but it can be intercepted by decorators.

Syntax:
module_name.value('name', 'value')

name --> instance name
value --> the value of instance

Example:

1, Create a module
var myApp = angular.module('app', []);

2. Add value to module

myApp.value("clientId", "123456");

3, Inject value to your controller function to use it

myApp.controller('MyController', function (clientId) {
  console.log(clientId);
});

No comments:

Post a Comment