Created
          June 19, 2016 09:13 
        
      - 
      
- 
        Save vigor-rus/724780780f5df0a5a26588b46ff78675 to your computer and use it in GitHub Desktop. 
    angular defaults from https://glebbahmutov.com/blog/angular-nuggets/
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | function defaults(_defaults, opts) { | |
| opts = opts || {}; | |
| return angular.extend(angular.copy(_defaults), opts); | |
| } | |
| function foo(options) { | |
| var _defaults = { | |
| bar: 'baz' | |
| }; | |
| options = defaults(_defaults, options); | |
| } | |
| foo({ bar: 'my bar' }); // options is { bar: 'my bar' } | |
| foo(); // options is { bar: 'baz' } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment