0

我有一个小的 angularjs 应用程序和小路由问题。

$routeProvider.when('/accounts', {templateUrl: 'app/partials/accounts.html', controller: 'accountsListController'});

a href="#/accounts"

这是我的控制器;

appControllers.controller("accountsListController", function($rootScope, $scope, accountsService, Page){
    $scope.$emit('START_LOAD');

    Page.setTitle("Hesaplar");

    $scope.status;
    $scope.accounts;

    获取账户();

    函数 getAccounts() {
        accountsService.getAccounts()
            .成功(函数(accs){
                $scope.accounts = accs.accounts;
                $scope.$emit('STOP_LOAD');
            })
            .error(函数(错误){
                $scope.status = '无法加载账户数据:' + error.message;
            });
    }

});

当我第一次单击 /accounts 链接时,我的控件、休息请求......一切都完美加载。但是,在同一条路线上,我再次单击 /accounts 链接,没有重新加载或触发。

所有路由请求一次工作,不刷新,示例小提琴http://jsfiddle.net/munsal/BUg8L/11/

我在哪里做错了?

(对不起我的英语不好)

4

3 回答 3

1

我更新了你的jsfiddle。它是否按您想要的方式工作?我只/$routeProvider.

于 2013-09-21T10:21:11.930 回答
0

回答我的问题。解决方案是使用 angularjs ngHref 指令。

网页:http ://docs.angularjs.org/api/ng.directive:ngHref

于 2013-10-16T22:53:59.887 回答
0

消除

 $scope.$emit('START_LOAD');
 $scope.$emit('STOP_LOAD');

并尝试

于 2013-09-20T21:04:27.577 回答