I have to use jQuery just because ng-grid needs it. But now I have some problem. In directive, when I try to use angular's element, function returns me jQuery element. But if I remove jQuery from page, everything works just fine.
Is there any way to correct this?
app.directive('dynamic', function($compile) {
return {
restrict: 'A',
replace: true,
link: function(scope, ele, attrs) {
scope.$watch(attrs.dynamic, function(html) {
console.log(ele) //HERE
ele.html(html);
$compile(ele.contents())(scope);
});
}
};
})
When I have jQuery, element looks like this:
[div, context: div, jquery: "1.11.0", constructor: function, selector: "", toArray: function…]
Otherwise:
[div, ready: function, toString: function, eq: function, push: function, sort: function…]
(I know it is not the full array, but you can see the difference).
- Example without jQuery: http://liveweave.com/05cWsP
- Example with jQuery: http://liveweave.com/w6QTpy