{"action":"created","issue":{"url":"https://api.github.com/repos/lemonde/angular-ckeditor/issues/7","labels_url":"https://api.github.com/repos/lemonde/angular-ckeditor/issues/7/labels{/name}","comments_url":"https://api.github.com/repos/lemonde/angular-ckeditor/issues/7/comments","events_url":"https://api.github.com/repos/lemonde/angular-ckeditor/issues/7/events","html_url":"https://github.com/lemonde/angular-ckeditor/issues/7","id":54835685,"number":7,"title":"Error while removing the editor","user":{"login":"pangwa","id":927678,"avatar_url":"https://avatars.githubusercontent.com/u/927678?v=3","gravatar_id":"","url":"https://api.github.com/users/pangwa","html_url":"https://github.com/pangwa","followers_url":"https://api.github.com/users/pangwa/followers","following_url":"https://api.github.com/users/pangwa/following{/other_user}","gists_url":"https://api.github.com/users/pangwa/gists{/gist_id}","starred_url":"https://api.github.com/users/pangwa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pangwa/subscriptions","organizations_url":"https://api.github.com/users/pangwa/orgs","repos_url":"https://api.github.com/users/pangwa/repos","events_url":"https://api.github.com/users/pangwa/events{/privacy}","received_events_url":"https://api.github.com/users/pangwa/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-01-20T02:15:09Z","updated_at":"2015-09-24T22:55:13Z","closed_at":null,"body":"With the callback below:\r\n\r\nTypeError: Cannot read property 'clearCustomData' of null\r\n    at CKEDITOR.tools.createClass.proto.detach (http://localhost:8089/ckeditor/ckeditor.js:784:341)\r\n    at CKEDITOR.editor.editable (http://localhost:8089/ckeditor/ckeditor.js:352:219)\r\n    at CKEDITOR.tools.extend.destroy (http://localhost:8089/ckeditor/ckeditor.js:243:307)\r\n    at onDestroy (http://localhost:8089/vendor/angular-ckeditor/angular-ckeditor.js:137:16)\r\n    at l.$get.l.$broadcast \r\n"},"comment":{"url":"https://api.github.com/repos/lemonde/angular-ckeditor/issues/comments/143070872","html_url":"https://github.com/lemonde/angular-ckeditor/issues/7#issuecomment-143070872","issue_url":"https://api.github.com/repos/lemonde/angular-ckeditor/issues/7","id":143070872,"user":{"login":"zourtney","id":880060,"avatar_url":"https://avatars.githubusercontent.com/u/880060?v=3","gravatar_id":"","url":"https://api.github.com/users/zourtney","html_url":"https://github.com/zourtney","followers_url":"https://api.github.com/users/zourtney/followers","following_url":"https://api.github.com/users/zourtney/following{/other_user}","gists_url":"https://api.github.com/users/zourtney/gists{/gist_id}","starred_url":"https://api.github.com/users/zourtney/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zourtney/subscriptions","organizations_url":"https://api.github.com/users/zourtney/orgs","repos_url":"https://api.github.com/users/zourtney/repos","events_url":"https://api.github.com/users/zourtney/events{/privacy}","received_events_url":"https://api.github.com/users/zourtney/received_events","type":"User","site_admin":false},"created_at":"2015-09-24T22:55:13Z","updated_at":"2015-09-24T22:55:13Z","body":"Hi @Yvem, I'm experiencing this problem. Simplified Plunkr here:\r\nhttp://plnkr.co/edit/mFLgPZBhMuuYvVl3FL3W?p=preview\r\n\r\nSince the `readyDeferred.promise.then` callback isn't executed synchronously, whatever object / element CKEditor is looking for is already gone.\r\n\r\n-----\r\n\r\nI tried adding a simple `isReady` flag. It feels redundant, but seems to work fine. Thoughts?\r\n\r\n```javascript\r\nvar isReady = false;\r\n\r\n...\r\n\r\nthis.onCKEvent('instanceReady', function() {\r\n    readyDeferred.resolve(true);\r\n    isReady = true;\r\n});\r\n\r\n...\r\n\r\n$scope.$on('$destroy', function onDestroy() {\r\n    if (isReady) {\r\n        instance.destroy(true);\r\n    }\r\n});\r\n"}}