app.directive('scroll', function() {
return {
restrict: 'EA',
link: function postLink(scope, element, attrs) {
var hasOverflowScrollingSupport = true; // for tests
if(hasOverflowScrollingSupport){
// use native scrolling with
// -webkit-overflow-scrolling:touch;
element.addClass('overflow-scrolling');
}
else {
// use iScroll
var opts = scope.$eval(attrs.scroll || attrs.scrollOpts || {}),
scroll = new iScroll(element[0], opts);
}
}
};
});
But I have already an iscroll directive. So maybe, the scroll directive could add the iscroll directive to the element if hasOverflowScrollingSupport is false. Is it possible to add a directive from a directive ?
Thx