The application is running on sails.js as backend and Angular as frontend, 
It is CRUD application and there two pages, one is the main Dashboard and 
other is Search.html that have advanced search functionalities.

here the thing two pages, use identical ng-repeat that inject same html 
page which contain same function with same controller that use same service.

Here how it goes, I click on the delete button which fire 
showCancelQuoteModal(quote), then I click on the confirmation and fire 
ng-click=cancelQoute which pass decisionFrom without any problems.

now in cancelQouteModalCtrl both qoute and decisionForm are passed without 
a problem to qouteLogService, where qoute still there and qoutelog contain 
cancellationReason.

and qoute.post should return createdQouteLog but it doesn't in search .html 
and does in Dashboard.html

when I started tracking and watching the var, everything disappear when the 
code get in Angular.js and the following stack

$scope.apply() / $scope.digest() /$scope.eval() /processQueue()

here the table of Dashboard.html and search.html

   <table class="table table-striped table-responsive" ui-jq="footable" 
data-filter="#filter19"
                   data-page-size="{{pageControl.pageSize}}">
              <thead>
              <tr>
                <th data-type="date">Last Update</th>
                <th>Client</th>
                <th>Phone</th>
                <th>Dealer</th>
                <th>Assigned To</th>
                <th data-type="numeric">Status</th>
                <th>Progress</th>
                <th>Actions</th>
              </tr>
              </thead>
              <tbody>

              <tr ng-repeat="quote in allQuotes | orderBy: '-updatedAt' track 
by quote.id"
                  ng-init="latestQuoteLog=findLatestQuoteLog(quote.quoteLogs)">
                <td class="text-center" 
data-value="{{latestQuoteLog.createdAt}}">
                  {{latestQuoteLog.createdAt | date : 'dd-MMM-yy hh:mm a'}}
                </td>

                <td>{{quote.client.name}}</td>

                <td>{{quote.client.phone | tel}}</td>

                <td 
ng-if="quote.dealershipCompany">{{quote.dealershipCompany.name}}</td>
                <td ng-if="!quote.dealershipCompany">Online</td>

                <td>{{username(latestQuoteLog.assignedTo)}}</td>

                <td data-value="{{latestQuoteLog.status}}">
                    <span class="label 
bg-{{quoteStatusIdToStatusName[latestQuoteLog.status]}}">
                      {{quoteStatusPrettyNames[latestQuoteLog.status]}}
                    </span>
                </td>
                <td>
                  <div class="progress-xs progress ng-isolate-scope w-sm 
m-t-sm" type="info">
                    <div class="progress-bar progress-bar-primary" 
role="progressbar"
                         
aria-valuenow="{{quoteStatusProgress[latestQuoteLog.status]}}" aria-valuemin="0"
                         aria-valuemax="100" ng-
                         style="width: 
{{quoteStatusProgress[latestQuoteLog.status]}}%;"></div>
                  </div>
                </td>
                <td>
                  <div class=" btn-group">
                    <button class="btn btn-sm btn-icon btn-default"
                            ng-if="latestQuoteLog.status != 
quoteStatus.quoteCancelled"
                            ng-click="showCancelQuoteModal(quote)">
                      <i class="glyphicon glyphicon-remove" tooltip="Cancel 
Quote"></i>
                    </button>
                    <button class="btn btn-sm btn-icon  btn-default" 
ng-click="editQuote(quote)">
                      <i class="glyphicon  glyphicon-edit" tooltip="Edit 
Quote"></i>
                    </button>
                    <button class="btn btn-sm btn-icon  btn-default" 
ng-click="viewQuote(quote)">
                      <i class="glyphicon  glyphicon-eye-open" tooltip="View 
Quote"></i>
                    </button>
                    <button class="btn btn-sm btn-icon  btn-default"
                            ng-click="showModal(quote, roles.broker, 'AT', 
latestQuoteLog)"
                            ng-if="canAssign(latestQuoteLog, roles.broker)">
                      <i class="glyphicon  glyphicon-arrow-right" 
tooltip="Assign To Broker"></i>
                    </button>
                    <button class="btn btn-sm btn-icon  btn-default"
                            ng-click="showModal(quote, roles.processor, 'AT', 
latestQuoteLog)"
                            ng-if="canAssign(latestQuoteLog, roles.processor)">
                      <i class="glyphicon  glyphicon-arrow-right" 
tooltip="Assign To Processor"></i>
                    </button>
                    <button class="btn btn-sm btn-icon  btn-default" 
ng-click="showModal(quote, roles.broker, 'CA')"
                            ng-if="canChangeAssignee(latestQuoteLog, 
roles.broker)">
                      <i class="glyphicon  glyphicon-transfer" tooltip="Change 
Assignee"></i>
                    </button>
                    <button class="btn btn-sm btn-icon  btn-default"
                            ng-click="showModal(quote, roles.processor, 'CA')"
                            ng-if="canChangeAssignee(latestQuoteLog, 
roles.processor)">
                      <i class="glyphicon  glyphicon-transfer" tooltip="Change 
Assignee"></i>
                    </button>
                  </div>
                </td>
              </tr>

              </tbody>
              <tfoot class="hide-if-no-paging">
              <tr>
                <td colspan="9" class="text-center">
                  <ul class="pagination"></ul>
                </td>
              </tr>
              </tfoot>
            </table>

Enter code here...


Here cancel Modal

  <script type="text/ng-template" id="cancelQuoteModal.html">

      <div class="modal-header">
        <form name="decisionForm" class="form-horizontal wrapper input-set">
          <div class="col-md-10">
            <label>
              <h4 class="font-thin">Why it is not sold ?</h4>
            </label>
            <select class="form-control" ng-model="reasonForRejection" 
name="reasonForRejection" required>
              <option ng-repeat="reason in rejectionReasons" value="{{reason}}">
                {{reason}}
              </option>
            </select>
            <small
              ng-show="(decisionForm.reasonForRejection.$invalid && 
!decisionForm.reasonForRejection.$pristine) || showErrors"
              class="b-light  m-t-n-sm m-b font-thin text-danger m-r">Reason is 
required.
            </small>
          </div>
        </form>
      </div>

      <div class="modal-footer">
        <button class="btn btn-sm btn-success" 
ng-click="cancelQuote(decisionForm)">Confirm Quote Cancellation</button>
        <button class="btn btn-warning" ng-click="cancelBox()">Close!</button>
      </div>

    </script>

Enter code here...


here cancelModalController

 .controller('cancelQuoteModalCtrl', ['$scope', '$modalInstance', 
'quoteLogService', 'rejectionReasons', 'quote', function ($scope, 
$modalInstance, quoteLogService, rejectionReasons, quote) {
    $scope.rejectionReasons = rejectionReasons;
    $scope.reasonForRejection;

    $scope.cancelQuote = function (decisionForm) {
      if (decisionForm.$invalid) {
        $scope.showErrors = true;
      } else {
        quoteLogService.create(quote, {
          'status': 'quoteCancelled',
          'cancellationReason': $scope.reasonForRejection
        }, function (createdQuoteLog) {
          $modalInstance.close('Quote cancelled successfully!');

        }, function (err) {
          $modalInstance.dismiss('Error creating new quoteLog');
          console.log('Error creating new quoteLog', err);
        });
      }
    };

    $scope.cancelBox = function () {
      $modalInstance.close();
    };

  }]);


here QuotLogService.js

QuoteLogModule
.factory('quoteLogService', ['$localStorage', '$state', 'LoggedInRestangular', 
function($localStorage, $state, LoggedInRestangular) {
    return {
        create: function(quote, quotelog, success, error) {
            quote.post('quotelog', quotelog).then(function(createdQuoteLog) {
                success(createdQuoteLog);
            }, function(err) {
                error(err);
            });
        },



-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to