After implementing a JS code snippet as shown below:
exports.openTab = function(location)
{
var $state = app.getInjector().get( '$state' );
var opts = {};
var toParams = {};
toParams.id = "myPage";
$state.go(location, toParams, opts);
exports.executeUsecase();
};
While the state.go function successfully opens the specified location, an issue arises as it immediately triggers the executeUsecase() method which has dependencies on the opened location. How can I ensure that the location is opened properly before calling the execute method? I've heard about "stateChangeSuccess" but unsure how it can be utilized to open a specific url location?