title: Promise being called twice in AngularJS
body: <p>Actually my promise execution starts here in <code>if</code> condition everything working fine but the problem is service call getting called twice the function <code>opmodel.concactDetails</code> is getting invoked twice.</p>
  
  <p>I am calling the <code>concatDetails</code> Once return a promise it calling <code>getPortfolio</code> which service but I not able to understand why its invoked twice</p>
  
  <pre><code>model.gridevents = function () {                            
      if (!opmodel.filterData.portfolioID) {
          opmodel.concactDetails(true)
          .then(model.setportifolioDetails)
          .then(model.getDrawsDetails);
      }
      gridPagination.setGrid(grid);
      gridTransform.setGridModel(grid);
      gridTransform.setGridPaginationModel(gridPagination);
      gridPagination.setData(gridPaginationConfig);
      return model;
  };
  
  model.setportifolioDetails = function (resp) {
      opmodel.setportifolioDetails(resp);
      model.getDrawsDetails();
  };
  
  model.getDrawsDetails = function () {
      model.setBusyIndicator(true);
      svc.getDrawsDetails(opmodel.filterData)
          .then(model.bindDraws, model.error);
  };
  </code></pre>
  
  
  
  <pre><code>model.concactDetails = function (flag) {
      model.flag = flag;
      var data = {
          data: {
              contact: session.get('contact'),
              portalsettings: session.get('portalsettings'),
              companyName: session.get('companyName'),
              epayEnabled: session.get('epayEnabled'),
              prodName: session.get('prodName'),
              showProductName: session.get('showProductName'),
              userRole: session.get('userRole'),
              statementPeriodCustom: session.get('statement_period_custom'),
          }
      };
      return model.updateFilterDetails(data);
  };
  </code></pre>
  
  
  
  <pre><code>model.updateFilterDetails = function (resp) {
      model.filterData = {
          setDefault: true,
          startDate: moment(resp.data.contact.portalDefaultStartDate).format("MM/DD/YYYY"),
          endDate: moment(resp.data.contact.portalDefaultEndDate).format("MM/DD/YYYY"),
          filterStartDate: moment(resp.data.contact.portalDefaultStartDate).format("YYYY-MM-DD"),
          filterEndDate: moment(resp.data.contact.portalDefaultEndDate).format("YYYY-MM-DD"),
          includeUnpaid: false,
          dateRangeFunction: resp.data.contact.portalDefaultFilterPeriod ?
              (resp.data.contact.portalDefaultFilterPeriod === "customPeriod()" &amp;&amp; resp.data.contact.customPeriodLabel === "None") ?
              "thisMonth()" : resp.data.contact.portalDefaultFilterPeriod : 'thisMonth()',
          customPeriodLabel: resp.data.contact.customPeriodLabel,
          portfolioID: resp.data.contact.portalDefaultPortfolioID,
          portfolioId: resp.data.contact.portalDefaultPortfolioID,
          epayInfo: resp.data.contact.epayInfo,
          epayEnabled: resp.data.epayEnabled,
          allowOwnerChangeBankInfo: resp.data.portalsettings.allowOwnerChangeBankInfo,
          showRealTimeData: resp.data.portalsettings.showRealTimeData,
          statementPeriodCustom: resp.data.statementPeriodCustom,
      };
      model.contactDetails = resp.data;
      if (!model.flag) {
          if (resp.data.portalsettings.showRealTimeBalances !== undefined &amp;&amp; resp.data.portalsettings.showRealTimeBalances !== true) {
              state.go("ownerPortal.alternateDashboard");
          }
      }
      model.flag = undefined;
      return model.portfolioData();
  };
  </code></pre>
  
  
  
  <pre><code>model.setportifolioDetails = function (resp) {
       if (resp.data.length &gt; 0) {
          model.portfolios = resp.data;
          model.filterData.portfolioID = model.filterData.portfolioID ?
              model.filterData.portfolioID : resp.data[0].id;
          model.filterData.portfolioId = model.filterData.portfolioID;
          model.portfolioName = _.find(resp.data, {
              id: model.filterData.portfolioId
          }).name;
       }
  };
  </code></pre>