# Reload same view with different data

**URL:** <https://forum.ionicframework.com/t/reload-same-view-with-different-data/13522>\
**Category:** uncategorized\
**Created:** [December 3, 2014, 10:32am UTC](https://forum.ionicframework.com/t/reload-same-view-with-different-data/13522 "2014-12-03T10:32:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![clanrbr](https://avatars.discourse-cdn.com/v4/letter/c/67e7ee/32.png) [@clanrbr](https://forum.ionicframework.com/u/clanrbr)\
**Post date:** [December 3, 2014, 10:32am UTC](https://forum.ionicframework.com/t/reload-same-view-with-different-data/13522/1 "2014-12-03T10:32:13Z")

</div>

Hello , I am using ionic and I have the following issue.

I have a search in the ion-nav-bar and i have function that $state.go to a state with resolve

```
.state('tab.textSearch', {
  url: '/textSearch/:searchText',
  resolve: {
    getSearchTextData : function(TextSearchData,$stateParams) {
        TextSearchData.emptyData();
        console.log('LoadDataFromResolve');
        return TextSearchData.getTextSearchData($stateParams.searchText);
    }
  },
  views: {
    'tab-home': {
      templateUrl: 'templates/tab-textSearch.html',
      controller: 'TextSearchCtrl'
    }
  }
});

```

**In the TextSearchData factory I have the following thing:**

```
myTextSearchResults.getTextSearchData = function(textSearchData) {
    $http.get("http://domain?search="+ textSearchData).success(function (d) {
      textData=d;
      console.log('loadDataFromQuery');
      deffered.resolve(d);
    });
    return deffered.promise;
  };

```

**And my controller looks like that:**

```
.controller('TextSearchCtrl', function($scope,$rootScope,getSearchTextData,TextSearchData) {
  console.log('LoadDataInController');
  $scope.searchItem=getSearchTextData;
})

```

So the first time I call the function It consoles:

1.LoadDataFromResolve  
2.loadDataFromQuery  
3.LoadDataInController

And everything is fine with the results,  
but when I am on the result screen - tab-textSearch.html and try to make another search it consoles  
1.LoadDataFromResolve  
2.LoadDataInController  
3.loadDataFromQuery

Does anyone know how could i fix that? Any help will be appreciated.

---

<div class="post-metadata">

**Author:** ![clanrbr](https://avatars.discourse-cdn.com/v4/letter/c/67e7ee/32.png) [@clanrbr](https://forum.ionicframework.com/u/clanrbr)\
**Post date:** [December 3, 2014, 10:35am UTC](https://forum.ionicframework.com/t/reload-same-view-with-different-data/13522/2 "2014-12-03T10:35:25Z")

</div>

Ok i saw where’s the problem i had to put the deffer inside the function

```
myTextSearchResults.getTextSearchData = function(textSearchData) {
var deffered = $q.defer();
$http.get("http://bazar.bg/api/ads/search?search="+ textSearchData).success(function (d) {
  textData=d;
  console.log('loadDataFromQuery');
  deffered.resolve(d);
});
return deffered.promise;

```

};
