Accessing a provider in config and controller

by Nico Po

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.6/angular.min.js"></script>
<div ng-app="myApp">
    <div ng-controller="myCtrl"></div>
</div>

JavaScript

angular.module('myApp', [])
        .provider('color', function(){
            var color = 'red'
            return {
                value : color,
                $get : function(){
                    return {
                        value : color
                    };
                }
            };
        })
        .config(function(colorProvider){
            console.log('color in config :',colorProvider.value);
            //you config here
        })
        .controller('myCtrl',function(color){
            console.log('color in ctrl :', color.value);
        });