Last active
June 29, 2018 01:51
-
-
Save maecha/55832779493740db373f1efe1a2aae29 to your computer and use it in GitHub Desktop.
Get the name of controller, from JS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getControllerName() { | |
// Ex) DOMAIN.com/NAME_SPACE/CONTROLLER_NAME/ACTION | |
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