我正在为$ scope.retryId分配一个值,if语句正在触发。但是,$ scope.retryId似乎正在重置其未定义的先前值。这是coffeescript:
retryModule.directive 'retryCall', () ->
restrict: 'EA'
scope:
retryId: '@'
showUrl: '@'
clearErrorsOnViewChange: '@'
clearSuccessOnViewChange: '@'
showSuccessfulRequests: '@'
showFailedRequests: '@'
taglineForError: '@'
taglineForSuccess: '@'
defaultErrorMessage: '@'
defaultSuccessMessage: '@'
template: """
.... Template Stuff .....
"""
# Directive Controller
# =====
# Handles the status report of $http requests
# - Shows failed requests and counts down until next automatic request attempt
# - Shows successful, non-GET responses
# - Allows user to manually retry failed requests
controller: [
'$scope',
'$http',
'$rootScope',
'$location',
'$interval',
'RetryCall',
($scope, $http, $rootScope, $location, $interval, RetryCall) ->
# _path: gives us our current url
_path = $location.path()
$scope.work = 'hii'
# Set defaults for all options
if !$scope.retryId?
# This will fire, but it will go back to undefined
$scope.retryId = true