0

Hy.

I will worked with angularjs but i have a little problem. It was my first App!

When I change route scroll to top not working.

//index.html        
        <body ng-app="WebApp">
          <div class="wrapper" >
            <div ng-include='"templates/sidebar.html"'></div>
            <div class="main-panel">
              <div ng-include='"templates/header.html"'></div>
              <div ng-view ></div>
            </div>
          </div>
        </body>

And my js file:

//app.js
var app = angular.module('WebApp', [
  'ngRoute','ui.bootstrap'
]);

app.config(['$routeProvider', function ($routeProvider) {
  $routeProvider
    // Home
    .when("/", {templateUrl: "partials/home.html", controller: "PageCtrl"})
    // Pages
    .when("/page_two", {templateUrl: "partials/page2.html", controller: "PageCtrl"})

    .when("/404", {templateUrl: "partials/404.html", controller: "PageCtrl"})
    .otherwise({ redirectTo: '/404'});
}]).run(['$rootScope', '$location', function($rootScope, $location){
   var path = function() { return $location.path();};
   $rootScope.$watch(path, function(newVal, oldVal){
     $rootScope.activetab = newVal;
   });


}]);


app.controller('PageCtrl', function (/* $scope, $location, $http */) {
});

I have tried window.scrollto in run -- not working. I have add autoscroll to ng-view and also not working. Here on stackoverflow works this for evryone but not for me? can anyone help?

joergi1988
  • 73
  • 1
  • 8
  • It looks like this is a duplicate of http://stackoverflow.com/questions/21055952/changing-route-doesnt-scroll-to-top-in-the-new-page – Valter Oct 14 '16 at 15:25
  • your `ng-app` name is different – Pradeepb Oct 14 '16 at 15:26
  • i have write i tried some here but not working with my app........ Its not duplicate.. i have tried all answers of this post – joergi1988 Oct 14 '16 at 15:33
  • Your problem is not clear. One general observation though: what is the purpose of having the same controller for all your pages? You normally have different pages for different purposes (and functionalities), and hence it would make sense to have different controllers as well. – FDavidov Oct 14 '16 at 15:57
  • ok. i'm new with angularjs. thanks – joergi1988 Oct 15 '16 at 10:03

0 Answers0