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

2 回答 2

0

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

于 2014-08-20T06:25:48.673 回答
0

它不起作用的第一个原因是 - jquery 不是角度摘要机制的一部分。
要使其工作,您应该应用位置更改:

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

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

$window.location('about')

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

于 2014-08-20T06:02:59.900 回答