     $message.toast "Load Project Failed."
 
 
+  ###
+   load issues according selected project.
+  ###
   loadIssues = ->
     url = $scope.selectedProject.account.url
     apiKey = $scope.selectedProject.account.apiKey

    $redmine(url, apiKey).issues.getOnProject(projectId, loadIssuesSuccess, loadIssuesError)


  loadIssuesSuccess = (data) ->
    url = $scope.selectedProject.account.url
    sameUrlTickets = (ticket for ticket in $scope.tickets when ticket.url is url)

    $scope.issues = data.issues


  ###
   show fail message.
  ###
  loadIssuesError = () ->
    $message.toast 'Failed to load issues'


  ###
   on project selection change, load issue on the project.
  ###
  $scope.onProjectChange = ->
    loadIssues()

