javascript - AngularJS full page refresh on the page I am visting, not the current one -
i using maphilight on main page if route different partial , return main page, maphilight stops working. however, if refresh page, works again. how force main page refresh every time navigate it? have seen people able refresh current page with
$scope.reloadpage = function(){window.location.reload();}
and
<a ng-click="reloadpage()" href="index.html#/diagram">back search</a>
but cant refresh page navigating to. in advance
here controller page linking to , want refresh:
roomcontrollers.controller('diagramcontroller', ['$scope', '$route', '$http', function($scope, $route, $http) { $http.get('js/master.json').success(function(data) { $scope.rooms = data; $scope.reloadpage = function(){window.location.reload();} }); }]);
here link in page coming from
<a ng-click="reloadpage()" href="index.html#/diagram">« search</a>
and here app code
var myapp = angular.module('myapp', [ 'ngroute', 'roomcontrollers' ]); myapp.config(['$routeprovider', function($routeprovider) { $routeprovider. when('/diagram', { templateurl: 'partials/diagram.html', controller: 'diagramcontroller' }). when('/diagram/:roomid', { templateurl: 'partials/room-details.html', controller: 'roomdetailscontroller' }). otherwise({ redirectto: '/diagram' }); }]); myapp.directive('highlight', function() { return { restrict: 'a', link: $(function(scope, element, attrs) { $('img[usemap]').maphilight(); })};
});
and html imagemap being highlighted:
<div class="info"> <img ng-src="images/housediagram.jpg" alt="photo of thing" class="map" usemap="#housemap" highlight> <map name="housemap" id="map"> <area ng-repeat="room in rooms" name="{{room.name}}" id="{{room.id}}" shape="poly" coords="{{room.coords}}" href="#/diagram/{{room.id}}" /> </map> </div>
try this, if looking full refresh of page.
myapp.controller('diagramcontroller', ['$scope', '$route', '$http', '$window', function($scope, $route, $http, $window) { $http.get('js/master.json').success(function(data) { $scope.rooms = data; $scope.reloadpage = function(){ $window.location.reload(); } }); }]);
Comments
Post a Comment