Override Link Function

I am working on an application using the excellent Bootstrap UI library . Everything works fine, but I came across an error with a camber plugin that crashes on IE10. I use the collapse plugin for the main navigator, and this gap is very complex, so I need to find a way around it.

I really don't want to hack into the main library. It looks like I would have to decorate this third-party directive using those found here here or here or here , but I can't get it to work.

In particular, I am trying to override the extend () function, which lives in the linkall link () function to check IE10 browser.

Has anyone done this or thought how to do this?

+6
source share
1 answer

Sure! You can decorate the directive and extend it or completely redefine it. Here is a great blog post

The easiest way is simply:

app.config(function($provide) { $provide.decorator('collapseDirective', function($delegate) { var directive = $delegate[0]; var link = function myLinkFnOverride(scope, element, attrs) { // code here... } directive.compile = function() { return function(scope, element, attrs) { link.apply(this, arguments); }; }; return $delegate; }); }); 

which will completely redefine the original link function (you will need to copy all its contents and change the elements you need)

+16
source

Source: https://habr.com/ru/post/983516/


All Articles