title: AngularJS $uibModal as a service with different controllers
body: <p>I'm sitting with this question for a while.</p>
  
  <p>I'm wondering how you can add different kind of controllers and different templateUrl from angularjs to <code>$uibModal</code>. So that You don't have that much code that actually does the same thing. Only on different <code>controller</code> and different <code>template</code>. </p>
  
  <h3>This is what I have done so far:</h3>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>vm.addDialogue = function () {
    vm.formData = {};
  
    var modalInstance = $uibModal.open({
      animation: true,
      templateUrl: 'views/modals/add.dialogue.html',
      controller: 'addDialogueController',
      controllerAs: 'vm',
      backdrop: 'static',
      resolve: {
        formData: function() {
            return vm.formData;
        },
        selectedTab: 1,
        editTime: false
      }
    });
  };
  
  vm.addProject = function(){
    vm.formData = {};
  
    var modalInstance = $uibModal.open({
      animation: true,
      templateUrl: 'views/modals/add.project.html',
      controller: 'addProjectController',
      controllerAs: 'vm',
      backdrop: 'static',
      resolve: {
        formData: function () {
          return vm.formData;
        }
      }
    });
  
      modalInstance.result.then(function (newProject) {
        vm.errorMessage = null;
          vm.projects.unshift(savedProject);
      }, function () {
        console.info('Modal dismissed at: ' + new Date());
      });
    }</code></pre>
  </div>
  </div>
  </p>
  
  <p>This works but I have five more of these Modals, I'm trying to find something that these seven fit in one function and not seven different functions.
  I have also tried putting this all in once controller instead of the controllers they belonged in. That worked for a moment but then it didn't showed some buttons that were supposed to be on a page. </p>