piwikHelper messup with angular

Hello there, I’m trying to update my plugin UI tweaks to the new date dropdown interface (since 3.14.x).

I need ajaxHelper to query APIs and discover if current user has admin privileges.
While it was working before, now I get an error inside the browser’s console but it’s piwikHelper related.

TypeError: angular.element(...).injector(...) is undefined piwikHelper.js:146:42
    getAngularDependency https://test/analytics/plugins/Morpheus/javascripts/piwikHelper.js?cb=e3188329d796f3c185829050d290a6f5:146
    _mixinDefaultGetParams https://test/analytics/plugins/Morpheus/javascripts/ajaxHelper.js?cb=e3188329d796f3c185829050d290a6f5:546
    _buildAjaxCall https://test/analytics/plugins/Morpheus/javascripts/ajaxHelper.js?cb=e3188329d796f3c185829050d290a6f5:417
    send https://test/analytics/plugins/Morpheus/javascripts/ajaxHelper.js?cb=e3188329d796f3c185829050d290a6f5:394
    <anonima> https://test/analytics/plugins/RerUserDates/javascripts/RerUserDates.js?cb=e3188329d796f3c185829050d290a6f5:24
    <anonima> https://test/analytics/plugins/RerUserDates/javascripts/RerUserDates.js?cb=e3188329d796f3c185829050d290a6f5:25

The piwikHelper problem is at getAngularDependency

My plugin’s code still untouched since months …
https://github.com/RegioneER/RerUserDates/blob/2.1.0/javascripts/RerUserDates.js

Any idea on what’s happening? I have no clue about Angular and there’s so much developers documentation about it…

Thanks for your time, best regards :sunny:

Hello! we don’t really know unfortunately. couple of thoughts

  1. Maybe at the time angular is not loaded yet and you could instead wrap all code within the method into $(function () { ... }) ?
  2. maybe it would help not to use require ?

Sorry I can’t be of more help :expressionless:

Well ok. The problem was 1st. Angular was not loaded.

So I just wrapped in a:

$(document).ready(function(){
  // my code
});

Thanks for hinting :smiley: