我使用的角度做一個畫布對象的深層副本,然後我得到Uncaught InvalidStateError: Failed to read the 'selectionDirection' property from 'HTMLInputElement': The input element's type ('checkbox') does not support selection.
angular.copy是無法複製的對象
canvas = document.getElementById('workercanvas')
canvas.width = cfg.labelsImage.width
canvas.height = cfg.labelsImage.height
ctx = canvas.getContext('2d')
clonedCanvas = null
if clonedCanvas is null
clonedCanvas = angular.copy(canvas)
有什麼想法? angular.copy可以複製DOM元素嗎?
更新:使用angular.element.clone 我試着用angular.element.clone,但問題是,它似乎它不作出深刻副本,我有以下幾點:
imgObj = new Image(imgWidth, imgHeight)
imgObj.onload = ->
ctx.drawImage(imgObj, 0, 0, imgWidth, imgHeight)
if clonedCanvas is null
clonedCanvas = angular.element.clone(canvas)
clonedImg = angular.element.clone(imgObj)
clonedCanvasContext = clonedCanvas.getContext('2d')
clonedCanvasContext.drawImage(clonedImg, 0, 0, imgWidth, imgHeight)
當我更改imgObj時,這也會影響克隆的Img並更改克隆的Canvas,我想以某種方式保留原始信息。是angular.element.clone
做了一個深層複製?
'可以通過angular.copy複製DOM元素嗎?'。第 – dfsq 2014-10-30 13:13:27
@dfsq任何建議的解決方案呢? – 2014-10-30 13:14:46
使用[element.clone()](https://docs.angularjs.org/api/ng/function/angular.element) – Blazemonger 2014-10-30 13:15:07