{"action":"created","issue":{"url":"https://api.github.com/repos/paoim/TrackingIssue/issues/7","repository_url":"https://api.github.com/repos/paoim/TrackingIssue","labels_url":"https://api.github.com/repos/paoim/TrackingIssue/issues/7/labels{/name}","comments_url":"https://api.github.com/repos/paoim/TrackingIssue/issues/7/comments","events_url":"https://api.github.com/repos/paoim/TrackingIssue/issues/7/events","html_url":"https://github.com/paoim/TrackingIssue/issues/7","id":147163776,"number":7,"title":"Create Directive in Angular for update file seems not work well","user":{"login":"paoim","id":6392108,"avatar_url":"https://avatars.githubusercontent.com/u/6392108?v=3","gravatar_id":"","url":"https://api.github.com/users/paoim","html_url":"https://github.com/paoim","followers_url":"https://api.github.com/users/paoim/followers","following_url":"https://api.github.com/users/paoim/following{/other_user}","gists_url":"https://api.github.com/users/paoim/gists{/gist_id}","starred_url":"https://api.github.com/users/paoim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paoim/subscriptions","organizations_url":"https://api.github.com/users/paoim/orgs","repos_url":"https://api.github.com/users/paoim/repos","events_url":"https://api.github.com/users/paoim/events{/privacy}","received_events_url":"https://api.github.com/users/paoim/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/paoim/TrackingIssue/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/paoim/TrackingIssue/milestones/1","html_url":"https://github.com/paoim/TrackingIssue/milestones/V2","labels_url":"https://api.github.com/repos/paoim/TrackingIssue/milestones/1/labels","id":1655458,"number":1,"title":"V2","description":"Will refactor on Rest URLs and also update on Web App for clients","creator":{"login":"paoim","id":6392108,"avatar_url":"https://avatars.githubusercontent.com/u/6392108?v=3","gravatar_id":"","url":"https://api.github.com/users/paoim","html_url":"https://github.com/paoim","followers_url":"https://api.github.com/users/paoim/followers","following_url":"https://api.github.com/users/paoim/following{/other_user}","gists_url":"https://api.github.com/users/paoim/gists{/gist_id}","starred_url":"https://api.github.com/users/paoim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paoim/subscriptions","organizations_url":"https://api.github.com/users/paoim/orgs","repos_url":"https://api.github.com/users/paoim/repos","events_url":"https://api.github.com/users/paoim/events{/privacy}","received_events_url":"https://api.github.com/users/paoim/received_events","type":"User","site_admin":false},"open_issues":4,"closed_issues":3,"state":"open","created_at":"2016-03-19T22:55:12Z","updated_at":"2016-04-09T21:08:35Z","due_on":"2016-06-30T05:00:00Z","closed_at":null},"comments":1,"created_at":"2016-04-09T21:08:35Z","updated_at":"2016-04-09T21:37:33Z","closed_at":null,"body":"Click upload file errors Uncaught Error: [$rootScope:inprog]\r\n\r\nhttp://errors.angularjs.org/1.2.21/$rootScope/inprog?p0=%24apply(anonymous function) @ angular.min.js:6m @ angular.min.js:104k.$digest @ angular.min.js:108D @ ui-bootstrap-tpls-0.11.0.min.js:9(anonymous function) @ angular.min.js:31q @ angular.min.js:7c @ angular.min.js:31loadFileDialog @ service-input-file.js:212$scope.openFileDialog @ controller-contact.js:178(anonymous function) @ angular.min.js:176(anonymous function) @ angular.min.js:193k.$eval @ angular.min.js:111k.$apply @ angular.min.js:112(anonymous function) @ angular.min.js:193(anonymous function) @ angular.min.js:31q @ angular.min.js:7c @ angular.min.js:31"},"comment":{"url":"https://api.github.com/repos/paoim/TrackingIssue/issues/comments/207856635","html_url":"https://github.com/paoim/TrackingIssue/issues/7#issuecomment-207856635","issue_url":"https://api.github.com/repos/paoim/TrackingIssue/issues/7","id":207856635,"user":{"login":"paoim","id":6392108,"avatar_url":"https://avatars.githubusercontent.com/u/6392108?v=3","gravatar_id":"","url":"https://api.github.com/users/paoim","html_url":"https://github.com/paoim","followers_url":"https://api.github.com/users/paoim/followers","following_url":"https://api.github.com/users/paoim/following{/other_user}","gists_url":"https://api.github.com/users/paoim/gists{/gist_id}","starred_url":"https://api.github.com/users/paoim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paoim/subscriptions","organizations_url":"https://api.github.com/users/paoim/orgs","repos_url":"https://api.github.com/users/paoim/repos","events_url":"https://api.github.com/users/paoim/events{/privacy}","received_events_url":"https://api.github.com/users/paoim/received_events","type":"User","site_admin":false},"created_at":"2016-04-09T21:37:33Z","updated_at":"2016-04-09T21:37:33Z","body":"**The code with error:**\r\n$scope.imageSource = \"\";\r\n$scope.isNewUploadImage = true;\r\n$scope.openFileDialog = function() {\r\n\tvar fileSelector = inputFileService.getSelectorById(\"contactAttachment\");\r\n\tinputFileService.loadFileDialog(fileSelector);\r\n\t\r\n\tinputFileService.addFileSelectedListener(fileSelector, function() {\r\n\t\t$scope.isNewUploadImage = false;\r\n\t\tvar files = this.files,\r\n\t\tphotoId = ($scope.contact.attachment ? $scope.contact.attachment : 0);\r\n\t\t\r\n\t\tif (files && files.length > 0) {\r\n\t\t\tvar file = files[0],\r\n\t\t\tfileName = file.name,\r\n\t\t\tfileSize = parseInt(file.size / 1024),\r\n\t\t\trequestData = {\r\n\t\t\t\tfileId : photoId,\r\n\t\t\t\tfileRequest : file,\r\n\t\t\t\tfileSize : file.size\r\n\t\t\t};\r\n\t\t\tconsole.log(\"Üpload file's size: \" + fileSize + \"KB\");\r\n\t\t\t\r\n\t\t\t//check to make sure it is not the same file's name\r\n\t\t\tif (!(fileName === $scope.contactAttachmentName)) {\r\n\t\t\t\tphotoService.uploadPhoto(requestData, function(data, message) {\r\n\t\t\t\t\tif (photoId > 0) {\r\n\t\t\t\t\t\t//Old Upload Photo\r\n\t\t\t\t\t\t$scope.contact.attachment = photoId;\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t//load image from byte Array to display on page\r\n\t\t\t\t\t\tphotoService.getByteArrayPhoto(photoId, function(data, message) {\r\n\t\t\t\t\t\t\t$scope.imageSource = utilService.getImageUrlBase64(data);\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\t//New Upload Photo\r\n\t\t\t\t\t\tphotoService.getLastPhoto(function(data, message) {\r\n\t\t\t\t\t\t\tvar newPhotoId = data.id;\r\n\t\t\t\t\t\t\t$scope.contact.attachment = newPhotoId;\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\tif (newPhotoId > 0) {\r\n\t\t\t\t\t\t\t\t//load image from byte Array to display on page\r\n\t\t\t\t\t\t\t\tphotoService.getByteArrayPhoto(newPhotoId, function(data, message) {\r\n\t\t\t\t\t\t\t\t\t$scope.imageSource = utilService.getImageUrlBase64(data);\r\n\t\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t}\r\n\t\t\t\t\t//console.log(message);\r\n\t\t\t\t});\r\n\t\t\t\t\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\t$scope.contactAttachmentName = fileName;\r\n\t\t}\r\n\t\t\r\n\t\t//clear input file after loading file dialog\r\n\t\tinputFileService.clearFileInput(this);\r\n\t\t\r\n\t});\r\n\t\r\n};"}}