$ location.path()在滚动绑定中不起作用

时间:2014-08-20 05:56:16

标签: javascript angularjs angularjs-directive ngroute angularjs-ng-route

 angular.module('example').service('myService', function
 myService($rootScope,$route,$http,$location) {                          
    $("#mainwindowscroll").on('scroll', function (e) {
          $location.path('/about');
    });
 });

2 个答案:

答案 0 :(得分:0)

它不起作用的第一个原因是 - jquery不是角度消化机制的一部分。
为了使其有效,您应该应用位置更改:

$rootScope.$apply(function() {
    $location.path('/about');
});

此外,请确保在您的应用模块中定义了位置(/ about)。否则你可以使用

$window.location('about')

导航到完全不同的路径(当然不要忘记注入$ window)。

答案 1 :(得分:0)

请确保您已为导航网址配置路由'/ about'?