Use service into View AngularJS

后端 未结 1 1473
攒了一身酷
攒了一身酷 2021-02-12 09:53

I have issue with angularJS Service.

I have simple service:

angular.module(\'mainApp.services\', []).factory(\'AuthService\',
function ($http) {
    //va         


        
1条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-12 10:40

    Using services inside the views is generally a bad practice. The view should contain only a presentation logic. In your example instead of passing the whole service to the view you could try to pass only a user object. For example $scope.currentUser = authService.currentUser().

    0 讨论(0)
提交回复
热议问题