I have a little problem with angularJS when it comes to finding elements.
It seems that my objects are changed when i use element.find('type').attr('id' ,someid);
Here some further information:
- I use the directive only in one position
 - I use angularjs 1.3.10.
 
i prepared a plunker http://plnkr.co/edit/fW4HsbqRhMWiw8hSLTVH?p=preview which shows what i mean. It alerts the previous found element after it has found another. What happens is that the previously found element is the same as the now found element ( a little bit tricky to explain, see the comments in the code to see what exactly i mean).
My link function looks so:
function link(scope,element,attrs)
{
    var _gradientCanvas = element.find('canvas').attr('id' , 'chColorGradient');
    if(_gradientCanvas[0].id === 'chColorGradient')
    {
        var _gradientContext = _gradientCanvas[0].getContext('2d');
    }
    var _overlayCanvas = element.find('canvas').attr('id' , 'chColorGradientOverlay');
    if(_overlayCanvas[0].id === 'chColorGradientOverlay')
    {
        var _overlayContext = _overlayCanvas[0].getContext('2d');
        alert(_gradientCanvas[0].id); //alerts: chColorGradientOverlay , but it should alert chColorGradient
    }
    var _arcOverlay = element.find('canvas').attr('id' , 'chColorArcOverlay'); 
    if(_arcOverlay[0].id === 'chColorArcOverlay')
    {
        var _arcContext = _arcOverlay[0].getContext('2d');
        alert(_gradientCanvas[0].id);//alerts: chColorArcOverlay , but it should alert chColorGradient
        alert(_overlayCanvas[0].id);//alerts: chColorArcOverlay , but it should alert chColorGradientOverlay
    }
}
Here is the template
<canvas class="chColorPickerCanvas" id="chColorGradient" width="255px" height="255px">
</canvas>
<canvas class="chColorPickerCanvas" id="chColorGradientOverlay" width="255px" height="255px">
</canvas>
<canvas class="chColorPickerCanvas" id="chColorArcOverlay" width="255px" height="255px">
</canvas>
i am not quite sure why it does this. i tried to debug into it with netbeans but it seems really that it changes my var _gradientCanvas etc after i called element.find another time.
Is there a reason for this ?