Items not updated in collection-repeat


#1

Hi guys,

I’m new on Ionic and i have a problem…

I’m trying to filter a set of data from Sqlite DB but it seems doesn’t work. Only works on ng-init method.


JS

$scope.initSearch = function(){
$scope.current =$stateParams.str;
$scope.itemsFetched= [];
console.log(“SELECT * FROM testimages WHERE message LIKE '%”+ $scope.current.toLowerCase()+"%’ ORDER BY message");
$cordovaSQLite.execute(db, “SELECT * FROM testimages WHERE message LIKE '%”+$scope.current.toLowerCase()+"%’ ORDER BY message")
.then(
function(result) {
console.log(result);
if (result.rows.length > 0) {
for(var i = 0; i < result.rows.length; i++) {
$scope.itemsFetched.push({id: result.rows.item(i).id, message: result.rows.item(i).message , imageDetalle: result.rows.item(i).imageDetalle});
}
}
}
);

$scope.filt = function ()
{
$scope.current =“Hexagonal”;
$scope.itemsFetched = [];
$cordovaSQLite.execute(db, “SELECT * FROM testimages WHERE message LIKE '%”+ $scope.current.toLowerCase()+"%’ ORDER BY message")
.then(
function(result) {
console.log(result);
if (result.rows.length > 0) {
for(var i = 0; i < result.rows.length; i++) {
$scope.itemsFetched.push({id: result.rows.item(i).id, message: result.rows.item(i).message , imageDetalle: result.rows.item(i).imageDetalle});
}
}
}
);
}

HTML

<script id="searchPage.html" type="text/ng-template">
         <!-- The title of the ion-view will be shown on the navbar -->
         <ion-view id="searchp" ng-controller="SearchController" class="searchPage" title="AtlasMX" cache-view="false">
         <ion-nav-buttons side="right">
          <a  class="button button-icon icon ion-funnel" ng-click="filt()" ></a> 
          <a class="button button-icon icon ion-search" ng-click="setBlur()"></a> 
          </ion-nav-buttons>        
           <div class="currentSearch" id="currentSearch" ng-hide="hideSearch" >
              <p>{{current}}
              </p>
              </div>
          <div class=" modalSearch animate-hide" id="modalSearchid" ng-hide="!hideSearch" >
                <label class="searchText item item-input search-input searchTextPage">
                  <input  id="inputSearchPage" style="text-align: center; font-size: 5vh;align=middle;height:100%;" type="search" placeholder="Nueva Búsqueda" autocomplete="off" autocapitalize="off" spellcheck="false" autocorrect="off">
          </div>
           <ion-content  overflow-scroll="true" id="contentSearch" ng-hide="false"  ng-init="initSearch()" ng-hide="hideSearch">
              <ion-content has-tabs="true">
        <div class="list">
        <a class="item no-padding"
          collection-repeat="itemFetched in itemsFetched "
          collection-item-height="80%"
          collection-item-width="'50%'">  
          <img ng-src="{{itemFetched.imageDetalle}}" class="adjusted no-padding" />
          <div class="envelope"  style="background: rgba(0, 0, 0, .0);" width="100%" height="100%">
                               <div class="footer" style="position: fixed; bottom: 0px; left: 0px; width: 100%; color: #fff; background-color:black; background: rgba(0, 0, 0, .43); height:15%; margin:0em; "  >
                                    <p style="height:50%;vertical-align: text-bottom;align-items: center;">
                                      {{itemFetched.message}}
                                    </p>
                                    <p style="height:50%;vertical-align: middle;">
                                      {{itemFetched.message}}
                                    </p>
                                </div>
                                
                          </div>
        </a>
      </div>

              </ion-content>
              
         </ion-view>
      </script>

When i enter on the page the data is displayed correctly but when i click nav button to trigger filt() function and filter using text “hexagonal”, the rows result are displayed in console but doesn’t appears on collection i mean the collection doesn’t update.

Sorry for my English.

I hope u understand.

Regards.