AngularJS - routeProvider resolve calling a service method

前端 未结 2 1562
感情败类
感情败类 2021-02-05 07:58

I\'ve created a service which checks the user login state (log the user in if token exists, otherwise redirect to login page).

Originally I called this service through t

2条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-05 08:05

    Adding to @Ajay's response, you can use a string rather than a standard property name, which will help with minification:

    resolve: {
        'myVar': function (repoService) {
            return repoService.getItems().then(function (response) {
                return response.data;
            });
        }
    }
    

提交回复
热议问题