0

This is a semi-strange problem.

I've got an Angular 4 project with a bunch of external libraries. The one I'm referencing here in particular is the PrimeNG library. More specifically, the Schedule portion which is essentially FullCalendar.

I need to extend this functionality, but I absolutely cannot figure out how to extend the Schedule prototype. If I go into the schedule.js file inside node_modules and edit the file directly, this is easy. I type:

Schedule.prototype.refreshEvents = function() { **do things** };

But obviously I don't want to have to modify anything in node_modules directly as it will just get replaced next update (and I can't distribute easily to my team).

I've tried declaring it in the component (at various lifecycle hooks), I've tried declaring it in a in index.html, and more. I'm just not sure what to do here.

Is there any way to extend the functionality of a node_modules plugin like this without directly modifying the file?

Thanks!

3
  • You could try avoiding messing with the distributed js files for PrimeNG by extending from the class they wrote in typescript. Something like MySchedule extends Schedule. I haven't actually done that before myself, but I feel like that's a good place to start. I'll link the source code for Schedule from their github here. github.com/primefaces/primeng/blob/master/src/app/components/… Commented Jul 13, 2017 at 0:32
  • The biggest problem is that their distributed material is in transpiled JS. Is there a way to overcome this problem? Commented Jul 13, 2017 at 0:35
  • Related: stackoverflow.com/q/44927180/6680611 Commented Jul 13, 2017 at 0:48

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.