非angular指令下引入百度ueditor,路由切换之后,就会报错。例如:
TyepError:Cannot read property 'getSelection' of undefined
at dom.Range.Range.select (ueditor.all.js:5746)
at dom.Range.setCursor (ueditor.all.js:5301
at UE.Editor.execCommand (ueditor.all.js:13736)
at UE.Editor._callCmdFn (ueditor.all.js:7587)
at UE.Editor.execCommand (ueditor.all.js:7615)
at UE.Editor.me.execCommand (ueditor.all.js:20578)
at m.$scope.addNews (cms-controller.js:181)
at cms-controller.js:246
at angular.min.js:91
at angular.min.js:123
现在就使用我们的大杀器。
$scope.$on('$destroy', function() {
ue.destroy();
});
通过广播的方法,在路由切换的过程中,将ueditor销毁掉。懒人就有懒人解决的方法,不知道这个方法好不好,但是目的是达到辣。