title: How to fetch and search data in angular js?
body: <p>I have two functions fetch_orders and search_order in my scope. The fetch_order function works well but when i click the search button, the search_order function executes and displays error saying Error: [ngRepeat:dupes]. These two functions fetch data from the database and displays in the client side. Is there a better way to fetch and search orders? </p>
  
  <pre><code>&lt;div class="order-data" ng-repeat="order in orders" &gt;
      &lt;div class="ordered-product-image"&gt;
          &lt;img width="90%"  src="product_images/{{order.product_image}}"&gt;
      &lt;/div&gt;
      &lt;div class="product-contents"&gt;
         &lt;h4&gt;Product&lt;/h4&gt;
          &lt;h5 data-ng-bind="order.brand_title"&gt;&lt;/h5&gt;
          &lt;p data-ng-bind="order.product_title"&gt;&lt;/p&gt;
          &lt;p data-ng-bind="order.tarif_value_name"&gt;&lt;/p&gt;
        &lt;/div&gt;
  &lt;/div&gt;
  
  
  &lt;script src="js/jquery-3.1.1.min.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src = "js/angular.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
      var app = angular.module('orders-app', []);
      var start = 0;
      var limit = 3;
  
      var sStart=0;
      var slimit = 3;
      var isSearching=false;
      var sData="";
      var sFilter="";
      var n = 0;
      app.controller("order-content", function($scope, $http){
  
          $scope.fetch_orders=function(){
              isSearching = false;
              $http.post("_fetch_orders.php", {
                  action:"fetch_all",
                  "start":start,
                  "limit":limit
              }).then(function(success){
                  limit+=3;
  
                  if(success.data.length &gt; n){
                      $scope.orders = success.data;
                      n = success.data.length;
                  } else {
                      limit-=3;
                  }
  
              });
          }
          $scope.fetch_order();
  
          $scope.search_order = function(){
              n=0;
              isSearching = true;
              sFilter = $scope.search_filter;
              sData = $scope.search_data;
  
              if(sFilter!=null){
              $scope.orders=null;
              $http.post("_fetch_orders.php", {
                  action: "search",
                  start: sStart,
                  limit: slimit,
                  value: sData,
                  column: sFilter
              }).then(function(success){
                      slimit+=3;
                      $scope.orders = success.data;
                  });
              }
          }
  });
  &lt;/script&gt;
  </code></pre>