angular-ui-router

Angular ui.router, Creating an Optional First Path Param

不打扰是莪最后的温柔 提交于 2019-12-30 11:39:10
问题 Relatively new to working with Angular, but I couldn't seem to find any url aliasing or fully optional path params (something like {/var1}/:var2 when using ui.router's $stateProvider . I'm looking to have the following both be valid paths, ideally on the same state declaration so that I can call state changes using one or both params. /var1/var2 /var2 Naturally, I can use matches like the following, but none of these are true solutions. /:var1/:var2 , but this still requires an empty value

How can I persist sibling ui-views when changing state?

孤者浪人 提交于 2019-12-30 11:35:44
问题 I have 2 ui-view directives in my application. One contains subnavigation and the other is the actual page content. My subnavigation is a tree structure, and when you click on an end node (or a leaf) should be the only time the content view gets updated. Whenever you click non-leaf nodes in the subnavigation, I would like the content view to stay the same while the subnavigation view changes. What is happening is whenever I switch to a state that does not define one of the views, the view

AngularJS + Routing + Resolve

自古美人都是妖i 提交于 2019-12-30 11:29:10
问题 I'm getting this error: Error: Error: [$injector:unpr] http://errors.angularjs.org/1.3.7/$injector/unpr?p0=HttpResponseProvider%20%3C-%20HttpResponse%20%3C-%20DealerLeads Injector Unknown provider Here's my router (ui.router): $stateProvider .state('main', { url: "/main", templateUrl: "views/main.html", data: { pageTitle: 'Main Page' } }) .state('leads', { url: "/leads", templateUrl: "views/leads.html", data: { pageTitle: 'Dealer Leads' }, controller: 'DealerLeads', resolve: DealerLeads

Angular ui-router: keep same ui-view for child

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-30 10:39:33
问题 I need child state be able to use parent state's resolve functions. But I also need to keep same ui-view for both states. Here's a fiddle. And there's a code $stateProvider .state('parent', { url: "/", template: '<p>Hello {{parent.one}}</p><br>' + '<button ng-click="goToChild()">child</button><br>', // this one below work but I don't need it // template: '<p>Hello {{parent.one}}</p><br>' // + '<button ng-click="goToChild()">child</button><br>' // + '<div ui-view></div>', resolve: { test:

How to pass $state variable into 2 other sibling $states?

偶尔善良 提交于 2019-12-30 09:58:10
问题 Plnkr: https://plnkr.co/edit/Brmcxd2LjGVJ6DXwuJtF?p=preview Architecture: $login -> $container (contains $dashboard and $feed ), dashboard contains: $tickers , $tags , $viewHeader and $socialMedia components. Goal: tags needs to communicate and send a tag object into the viewHeader and socialMedia states. Expected: After Login , selecting a button in the Tags list should send that tag into the ViewHeader and SocialMedia states/components. Results: After Login , selecting a button in the Tags

How to pass $state variable into 2 other sibling $states?

放肆的年华 提交于 2019-12-30 09:58:04
问题 Plnkr: https://plnkr.co/edit/Brmcxd2LjGVJ6DXwuJtF?p=preview Architecture: $login -> $container (contains $dashboard and $feed ), dashboard contains: $tickers , $tags , $viewHeader and $socialMedia components. Goal: tags needs to communicate and send a tag object into the viewHeader and socialMedia states. Expected: After Login , selecting a button in the Tags list should send that tag into the ViewHeader and SocialMedia states/components. Results: After Login , selecting a button in the Tags

UI- Router — run function on every route change — where does the state name live?

独自空忆成欢 提交于 2019-12-30 06:27:12
问题 Using Angularjs and UI-Router, trying to run a function every time state changes $rootScope.$on('$stateChangeStart', function(toState){ if(toState !== 'login') UsersService.redirect(); }) I put this in .run() and i can successfully log out toState every time route changes. However, i can't seem to find the property which has the name of the state that we are going to. If someone can tell me where to find that, i think i should be in good shape. 回答1: Ended up with this and it does what i want.

UI- Router — run function on every route change — where does the state name live?

痴心易碎 提交于 2019-12-30 06:27:11
问题 Using Angularjs and UI-Router, trying to run a function every time state changes $rootScope.$on('$stateChangeStart', function(toState){ if(toState !== 'login') UsersService.redirect(); }) I put this in .run() and i can successfully log out toState every time route changes. However, i can't seem to find the property which has the name of the state that we are going to. If someone can tell me where to find that, i think i should be in good shape. 回答1: Ended up with this and it does what i want.

How to add guid regex in angular ui-router state

蓝咒 提交于 2019-12-30 05:28:10
问题 I have this route .state('mystate', { url: '/{id}', templateUrl: '/views/partial.html' }); The id param should be a guid in form like this "2a542f61-5fff-4607-845d-972e6c3ad1e4". How do i add this in the url "url: '/{id:?what should i put here}'". 回答1: You can define your own type of parameter. var GUID_REGEXP = /^[a-f\d]{8}-([a-f\d]{4}-){3}[a-f\d]{12}$/i; $urlMatcherFactoryProvider.type('guid', { encode: angular.identity, decode: angular.identity, is: function(item) { return GUID_REGEXP.test

AngularJS possible unhandled rejection when using ui-router

余生长醉 提交于 2019-12-30 04:28:06
问题 After I have changed from ngRoute to angular-ui-router the console shows always 4 errors stating: Possibly unhandled rejection: {} I did not noticed any "problem" in the behavior of the application I am building, but I would like to get rid of it. Any idea what does it mean and how to solve it? Here an screenshot: 回答1: This issue is found in 1.5.9 and 1.6.0-rc-0. More details at https://github.com/angular-ui/ui-router/issues/2889 Patch solution is to manually disable unhandled rejections. app