Adding third party directive problem

Adding third party directive problem

by Zoran Jeremic -
Number of replies: 2

Hi,

I'm trying to add ng-walkthrough directive to my addon in MM2. I did it successfully in one sample project, but I can't add it to moodle module. I added it ng-walkthrough.js and ng-walkthrough.html to myaddon/directives directory, installed bower package, but once I reach the page that uses walkthrough directive, I get the following error:


error

Do you have any idea where to look for the problem?


Thanks

Average of ratings: -
In reply to Zoran Jeremic

Re: Adding third party directive problem

by Dani Palou -
Picture of Core developers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Hi Zoran,

I've never used ng-walkthrough so I can't be of much use to you, but maybe I can give you some advice to debug the problem.

Sometimes our $log decorator gets in the middle of error reports, making it unable to know where is the error happening. In those cases I just turn it off replacing this line in core/main.js:

$provide.decorator('$log', ['$delegate', $mmLogProvider.logDecorator]);

and putting these lines instead:

$provide.decorator('$log', ['$delegate', function($log) {

        $log.getInstance = function(){ return $log; };

        return $log;

}]);

Sometimes you'll have to refresh several times or restart ionic serve to make it work. You'll know it works because the log entries won't have a timestamp anymore. E.g. instead of seeing:

"10/13/2015 6:10:46 PM $mmInitDelegate: Executing init process 'mmLogin'"

You'll just see:

"Executing init process 'mmLogin'"

Once you've turned the decorator off, please try to reproduce the error again. This time the error report might be more useful to you.

I hope this helps you figure out the problem!

Dani

In reply to Dani Palou

Re: Adding third party directive problem

by Zoran Jeremic -

Hi Dani,

Thank you for your answer. It seems that the problem is in the ng-walkthrough libarary itself. It has the problem when it's not directly included from index.html. If I include it's ng-walkthrough.js and ng-walkthrough.css, everything works fine, but when it's referenced from mm.bundle.js and mm.bundle.css, this problem exists.

Zoran