0
Я хочу вызвать функцию обслуживания с контроллера директивы. Имя службы Auth и имя функции Auth.logout. Я уже заказывал службу в контроллере директивы, но не работал. Пожалуйста, дайте мне знать Что делать? Сценарий написан в coffeescript.Использовать служебную функцию в директиве в angularjs
код Директива: -
class GlobalNav extends BaseDirective
@register 'globalNav', ->
restrict: "E"
templateUrl: 'templates/Directives/global-nav.jade'
controller: ($scope, $ionicSideMenuDelegate, $ionicPopup,Auth) ->
$scope.closeSideMenu = ->
$ionicSideMenuDelegate.toggleLeft(false)
$scope.showConfirm = ->
confirmPopup = $ionicPopup.confirm(
title: 'Message'
template: 'Are you sure you want to logout?')
confirmPopup.then (res) ->
if res
Auth.logout <<<<<<<<<<<<<<<<<<<<< This is not called
return
return
Auth код услуги: -
class Auth extends BaseService
@register 'Auth'
AUTH_KEY: 'userAuth'
AUTH_REJECTION: 'authentication'
constructor: (@$q, @$http, @$rootScope, @$cordovaFacebook, @storage, @Api, @$track, @FacebookAuth) ->
authenticated: -> !_.isEmpty(@_getAuth())
logout: ->
q = @$q.defer()
@storage.clearAll()
@_auth = null
@Api.expireGlobalCache()
@$cordovaFacebook.logout().then(q.resolve)
q.promise