Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.14/angular.min.js"></script>
  <meta charset="utf-8">
  <title>Validated constants</title>
<script>
  angular.module('MyApp.Constants', [])
  .config(function ($provide) {
    $provide.decorator('constant', function ($delegate) {
      return function(name, value) {
        // validate name/value
        return $delegate(name, value); 
      };
    });
  });
  angular.module('MyApp', ['MyApp.Constants'])
  .run(function ($rootScope, username) {
    // start using constants module
    $rootScope.username = username;
  });
</script>    
</head>
<body ng-app="MyApp">
  <script>
    // inject actual values when needed, the module already exists
    angular.module('MyApp.Constants').constant('username', 'World');
  </script>
  
  <p>Hello, {{ username }}</p>
</body>
</html>
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
bahmutovpro
0viewers