Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upDynamically / Programmatically Create Routes #90
Closed
Comments
|
It doesn't make sense to create states dynamically like that. The idea is that you have modelled all the states that the UI can be in up-front. For the specific case of error handling, I would either create a single state called 'error', or even remain in the state you're in and just push the error object into the root scope, and trigger the display of your error modal via the ui-if directive or a similar mechanism (essentially treating the whether or not an error exists as orthogonal to the normal UI state). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm looking to programmatically add a "/error" route to the end of the url when a call to the api fails. This in turn would change one of a parent's views to include a modal. Here is some pseudo code:
($api is a customer service I created)
customerCtrl = function($scope, $stateParams, $api) {
$api.get('customer',
{ //this is a callbacks object
success: function () { doSomething()},
error: function(reason){
switch(reason){
case 'customernotthere':
createErrorRoute({
url: $location.$$path + '/error',
template: '
controller: function(){ theController(); }})
break;
}
}})
};
Any ideas?