angular-ui-router

AngularJS ui-router: force reload

ぃ、小莉子 提交于 2019-12-30 01:41:22
问题 I have an AngularJS app starting at index.html and using ui-router. Based on a trigger I want to reload the complete page. I tried: $state.go($state.current, $stateParams, { reload: true, inherit: false, notify: true }); But that does not work. It doesn't reload my initial index.html. I can do: window.location.href = "index.html"; But then I'm on my initial page, not the current state. Should a set window.location.href to index.html with query string parameters specifying current location? If

Parameters for states without URLs in ui-router for AngularJS

▼魔方 西西 提交于 2019-12-30 00:31:05
问题 I am using ui-router to represent states in my AngularJS app. In it I'd like to change the state without changing the URL (basically a "detail view" is updated but this should not affect the URL). I use <a ui-sref="item.detail({id: item.id})"> to display the detail but this only works if I specify a URL like url: "/detail-:id" in my $stateProvider . It seems to me that the current state is only defined through the URL. 回答1: Thanks for your answer, it did help me in the right direction but I'd

angular ui-router parent url set to /

為{幸葍}努か 提交于 2019-12-29 18:49:21
问题 Using ui-router and setting the parent state url to / results in my url looking like localhost:8000/#//child when looking at a child page. I'd like just a single / between the hash and child. I tried leaving the parent state url blank, but then ui-sref won't link back to the parent state when using an anchor link. Anybody got a solution for having a root level un-named parent url? app.config app.config(function($stateProvider, $urlRouterProvider) { $urlRouterProvider.otherwise("/");

Parts of page as subviews in Angular

左心房为你撑大大i 提交于 2019-12-29 14:15:34
问题 I have the following problem to solve: From within local menu (menu on the left) I can choose sub pages. Typical scenario. And now I would like to relaod content associated with local menu item. In pure Angular I don't know a standard easy way to achieve it. I could get markup from the server manually and replace the content area manually. Is there a better way? I googled and came across https://github.com/angular-ui/ui-router Yet before I start delving into details perhaps you could advice

Angular UI-Router: child using parent's view

为君一笑 提交于 2019-12-29 11:47:22
问题 In story form: What I am looking for here is a master-detail setup. The master is in list form and when I click on a link (relative to a particular row/record (or Account in this case)) I want to see the details in the main view (literally, the "main" view: <div class="container" ui-view="main"></div> ). I want to do this and maintain my URL structure ( /accounts for the list of Accounts; /accounts/:id for the detailed version) but I want the detail view to use the view that the list was

Angular UI-Router: child using parent's view

柔情痞子 提交于 2019-12-29 11:46:04
问题 In story form: What I am looking for here is a master-detail setup. The master is in list form and when I click on a link (relative to a particular row/record (or Account in this case)) I want to see the details in the main view (literally, the "main" view: <div class="container" ui-view="main"></div> ). I want to do this and maintain my URL structure ( /accounts for the list of Accounts; /accounts/:id for the detailed version) but I want the detail view to use the view that the list was

Two calls triggering on click of post request using HttpClient [duplicate]

时光怂恿深爱的人放手 提交于 2019-12-29 08:24:14
问题 This question already has answers here : duplicate ajax calls in angularjs (2 answers) Closed 2 years ago . After adding headers inside code duplicate call is happening. find the image to see the call happening twice. auth-interceptor.ts export class AuthInterceptor implements HttpInterceptor { intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> { const clonedRequest = req.clone({ headers: req.headers.set('X-CustomAuthHeader', 'some-auth-token') }); console.log(

Defer Angular UI Router $stateChangeStart until server authorization response receieved

我与影子孤独终老i 提交于 2019-12-29 05:57:31
问题 I have an Angular app using UI Router where I'm trying to validate a user's token, if one exists, when the app runs. I am also checking that the user has permission to access certains routes. The problem is that $stateChangeStart is running before I receive the response back from the authorization endpoint. Here's some code (coffeescript with js below) - this is all within my run block. app.run(($rootScope, $state, $stateParams, $log, Auth) -> currentState = 'home' $rootScope.$state = $state

Changing the default behavior of $state.go() in ui.router to reload by default

假装没事ソ 提交于 2019-12-29 04:20:28
问题 I have an Angular app built using the ui.router package for its URL routing. I would like to change it so that if the user attempts to navigate to the page they're already on, the router reloads that state rather than doing nothing. Per http://angular-ui.github.io/ui-router/site/#/api/ui.router.state.$state#go, $state.go does take a reload parameter that will do exactly that, however it defaults to false. Now, it strikes me as a poor idea to rewrite every single call to $state.go and every ui

How to handle error in angular-ui-router's resolve

人盡茶涼 提交于 2019-12-29 03:24:14
问题 I am using angular-ui-router's resolve to get data from server before moving to a state. Sometimes the request to the server fails and I need to inform the user about the failure. If I call the server from the controller, I can put then and call my notification service in it in case the call fails. I put the call to the server in resolve because I want descendant states to wait for the result from the server before they start. Where can I catch the error in case the call to the server fails?