141
rated 0 times
[
147]
[
6]
/ answers: 1 / hits: 35226
/ 11 Years ago, tue, july 30, 2013, 12:00:00
I have a problem with document.ready in angularJS when navigating between several routes in my app. It only works when I use ctrl+f5 (page reload); it seems navigating between pages does not change state of the document to ready.
Controller
angular.element(document).ready(function() {
window.scrollTo(0,90);
});
Main html file
<!DOCTYPE html >
<html ng-app=myApp>
<head>
<meta http-equiv=content-type content=text/html;charset=utf-8 />
<title></title>
</head>
<body>
<div class=container>
<div ng-view></div>
</div>
</body>
</html>
app file
var mainModule = angular.module('myApp', ['ui.bootstrap.dialog']);
function viewServiceConfig($routeProvider) {
$routeProvider.
when('/', {
controller: SomeController,
templateUrl: 'somehtml.html'
}).
when('/someroute', {
controller: SomeRouteController,
templateUrl: 'someroutehtml.html'
}).
otherwise({
redirectTo: '/'
});
}
mainModule.config(viewServiceConfig);
More From » angularjs