I have a directive building html based on an array sent as attribute. I can't access it from the compiler function of the directive. It works inside the link function, but I need in inside the compile, otherwise new template doesn't get compiled.
Code is like this:
<multirangeslider values="ranges" variances="['Master', 'master A', 'master B']"></multirangeslider>
Directive:
angular.module("vtApp.directives").
directive('multirangeslider', function ($parse, $timeout, $compile) {
return {
restrict: 'E',
replace: true,
scope: {
values: "=",
options: "=",
variances: "&"
},
compile: function (element, attrs) {
var htmlText, variances, values;
variances = eval(attrs.variances);
values = scope.ranges //scope is undefined
values = eval (attrs.variances) //returns string "ranges"
values = ??? ///what should I put here?
htmlText = '<div></div>';
element.replaceWith(htmlText);
return function (scope, element, attrs){
}
}
}
});
Thank