title: How should I make configurable modules in Angular2
body: <p>I'm wondering what would be the best way to set up configurable modules in angular2. In angular1 this was done usually via providers. With them being changed quite a bit, how would you go about passing config parameters to reusable ng2 modules/directives/components?</p>
  
  <p>An <a href="https://github.com/johannesjo/angular-promise-buttons/blob/master/src/angular-promise-buttons-p.js" rel="noreferrer">ng1 example</a>:</p>
  
  <pre><code>// configuring a (third party) module    
  .config(function (angularPromiseButtonsProvider) {
    angularPromiseButtonsProvider.extendConfig({
      spinnerTpl: '&lt;div class="other-class"&gt;&lt;/span&gt;',
      disableBtn: false
    });
  });
  
   // setting up the provider
  .provider('angularPromiseButtons', function angularPromiseButtonsProvider() {
      var config = {
          spinnerTpl: '&lt;span class="btn-spinner"&gt;&lt;/span&gt;',
          priority: 0,
          disableBtn: true,
      };
  
      return {
          extendConfig: function(newConfig) {
              config = angular.extend(config, newConfig);
          },
  
          $get: function() {
              return {
                  config: config
              };
          }
      };
  })
  
  // using the result in the directive, etc.
  .directive('promiseBtn', function(angularPromiseButtons){
      var config = angularPromiseButtons.config;
  })
  </code></pre>
  
  <p>This is basically the same question as <a href="https://stackoverflow.com/questions/23600051/how-should-i-make-configurable-modules-in-angularjs">this one</a> but directed at angular2.</p>