I am trying to pass a $scope\'s variable to a directive, but its not working. I am catching the variable in the template function:
app.directive(\'customdir\', f
Or like this
app.directive('customdir', function ($compile) {
var getTemplate = function(filter) {
switch (filter) {
case 'World': return '';
default: return '';
}
}
return {
restrict: 'E',
scope: {
filterby: "="
},
link: function(scope, element, attrs) {
var el = $compile(getTemplate(scope.filterby))(scope);
element.replaceWith(el);
}
};
});
http://plnkr.co/edit/yPopi0mYdViElCKrQAq9?p=preview