Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Get the name of controller, from JS
getControllerName() {
// Ex)
var pathname = window.location.pathname; // /NAME_SPACE/CONTROLLER_NAME/ACTION
let splitedPathnames = pathname.replace(/\//, ''); // [ 'NAME_SPACE', 'CONTROLLER_NAME', 'ACTION' ]
return splitedPathnames.split('/')[1]; // CONTROLLER_NAME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment