Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamically / Programmatically Create Routes #90

Closed
btesser opened this issue Apr 16, 2013 · 1 comment
Closed

Dynamically / Programmatically Create Routes #90

btesser opened this issue Apr 16, 2013 · 1 comment

Comments

@btesser
Copy link

@btesser btesser commented Apr 16, 2013

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: '

the template
',
controller: function(){ theController(); }})
break;
}
}})
};

Any ideas?

@ksperling
Copy link
Member

@ksperling ksperling commented Apr 17, 2013

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).

@ksperling ksperling closed this Apr 17, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.