What is the difference between constant and value? we can change both values.
var app = angular.module(‘myApp’,[]); app.constant(‘appName’,‘My App’); app.value(‘applicationName’,‘Sample’);
Constants can fit anywhere, and values cannot be added anywhere. Also, constants cannot be intercepted by decorators, while values can be intercepted by decorators.
Also see: Value and Constants
The difference between value and permanent service is that the former can only be entered (and therefore used) in the service or while the latter can also be entered into the module (I will talk about the configuration of the module function in a future post).
1) 2)
1) 2) , , factory, config.
var app = angular.module('app', []); app.value('greeting', 'Hello'); app.config(function(greeting){ var radius = 4; //PI can be injected here in the config block var perimeter = 2 * PI * radius; });
, .
, . - , , - , .Values are great for pieces of data that can and will change. As shown above, user data or something else where you just want to keep a reference to a changing value stored globally without creating a messy global variable.
, . - , , - , .
Values are great for pieces of data that can and will change. As shown above, user data or something else where you just want to keep a reference to a changing value stored globally without creating a messy global variable.
full article: Constants and Values: Global Variables in AngularJS The Right Way
Source: https://habr.com/ru/post/1610270/More articles:Migrating a team project from TFS 2013 to TFS 2015 - tfsCMake ADD_CUSTOM_COMMAND with unknown output files - c ++https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1610267/add-items-to-select-list-on-the-client-side-in-mvc-5-asp&usg=ALkJrhjXi3JXZ9_0qLVtTDuThmM9_xumYQSet subtraction in Python - pythonWhy the variable is still bound - scopeВыход молчания в bash script с помощью функции рекомендуется? - linuxLaunch Windows Phone 8.1 app with deep link - windows-store-appsIs it possible to detect the Android portal browser in real time? - javascriptThe cleanest way to get a value from a list item is pythonDjango urls uuid not working - djangoAll Articles