I'm creating a module in Drupal 8 and I need to define a relative path to mymodule to pass it on a JavaScript file like this.
$scope.getPlatformIcon = function (_platform) {
var modulePath = "/modules/mymodule"
switch (_platform) {
case "youtube":
case "twitter":
case "instagram":
case "facebook":
return modulePath+"/img/"+_platform+".png";
}
return false;
};
In Drupal 7 I could use the following.
var modulePath = Drupal.settings.mymodule.basePath;
For the Drupal 8 root directory, I could use the following.
drupalSettings.path.baseUrl
I didn't find how to get the module path.
How can I do it with Drupal 8?