0

How can I refresh the injected template in angular with a button, because I tried to do this:

$scope.refreshData = function() {
  console.log("Trying to refresh...");
  $state.go($state.current, {}, {reload: true});
}

When this icon gets clicked:

<i class="fa fa-refresh pull-right" aria-hidden="true" ng-click="refreshData();"></i>

But the problem is, that the entire page gets refreshed, tbh I'm still learning angularJs.

Thanks.

vnv_nation
  • 25
  • 1
  • 4
  • You can `$compile` again the template. [Check this](http://stackoverflow.com/questions/21487617/how-do-i-make-angular-js-reevaluate-recompile-inner-html) – gianlucatursi Aug 31 '16 at 19:22
  • 1
    Sorry, I misread your question. What do you mean by refresh your template? – Kindzoku Aug 31 '16 at 19:22
  • The entire page is refreshed or only the content inside ui-view is refreshed? Because ui-view is the templateUrl.. – Gustavo Gabriel Aug 31 '16 at 19:22
  • The problem is that you're using $state.current. That means all states will refresh. You want to refresh only the specific state, so use $state.go(stateYouWantRefreshed) instead. – Chris Stanley Aug 31 '16 at 19:49
  • Well in the main html file, there are some "widgets (html templates)" that are injected , and each widget has a refresh button, but when the refresh button is clicked, the whole page gets refreshed, instead only the widget, only the widget has to be refreshed. @Kindzoku – vnv_nation Aug 31 '16 at 20:59
  • @ChrisStanley I looked through the code and I guess that the html files are injected with this `$http.get('modules/dashboard/partials/listWidgets.json'). success(function(data) { $scope.dashboardItems = data; configDashboardMobile(); }). error(function() { console.log('Error en la obtención de datos'); });` and in the html : `
    – vnv_nation Aug 31 '16 at 21:35

0 Answers0