Answer the question
In order to leave comments, you need to log in
How to use $compile correctly?
I'm trying to make an attribute directive, when hung, the current element will be copied via $(element).clone() and added before the current element, somehow modified and somehow moved by ondrag. The problem is that it has dynamic content, so you need to compile it. If I try to do $compile(clone)(scope); when preparing a clone, the application crashes from stackoverflow, if I compile in onDrag, wild brakes start.
function link(scope, element, attrs) {
....
$ionicGesture.on('dragright' onDrag, element);
clone = $(element).clone();
wrapper = $('<div> </div>').append(clone);
clone.css('position', 'absolute');
element.before(wrapper);
$compile(wrapper)(scope); //stack overflow
$compile(wrapper)(scope, function (clonned) { //опять stack overflow
element.before(clonned);
});
function onDrag() {
clone.css('left', ....) ;
$compile(wrapper)(scope); //Работает, но с дикими тормозами + контент {{}} успевает показаться
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question