angular-ui-router

Angular - ui-router get previous state

落花浮王杯 提交于 2019-12-17 08:00:55
问题 Is there a way to get the previous state of the current state? For example I would like to know what the previous state was before current state B (where previous state would have been state A). I am not able to find it in ui-router github doc pages. 回答1: ui-router doesn't track the previous state once it transitions, but the event $stateChangeSuccess is broadcast on the $rootScope when the state changes. You should be able to catch the prior state from that event ( from is the state you're

Angularjs ui-router abstract state with resolve

你。 提交于 2019-12-17 07:48:16
问题 Is it possible to make an abstract state with ui-router that needs to resolve data? I need to load the top half of a page with profile info, and then have a sub-nav that loads other details at the bottom of the page. The idea is that the abstract state would load the profile info every time regardless of which child state I am on. It doesn't seem to work. Example: .state('app.profile', { abstract: true, url: 'user/:username', views: { content: { templateUrl: 'views/frontend/profile.html',

How can I fix 'Maximum call stack size exceeded' AngularJS

£可爱£侵袭症+ 提交于 2019-12-17 07:39:12
问题 I am using AngularJs and Ui-Router and I am trying to set two different home pages, one for users that are logged in and the other for users that aren't. But I am getting the following error: RangeError: Maximum call stack size exceeded I ran console.trace() and I can see that there is an issue which is causing the states to loop infinitely (or something like that). BUt I have no idea how to fix it. Here is the code that is generating the error. .run(function ($rootScope, $state, $location,

Clear History and Reload Page on Login/Logout Using Ionic Framework

て烟熏妆下的殇ゞ 提交于 2019-12-17 07:15:07
问题 I am new to mobile application development with Ionic. On login and logout I need to reload the page, in order to refresh the data, however, $state.go('mainPage') takes the user back to the view without reloading - the controller behind it is never invoked. Is there a way to clear history and reload the state in Ionic? 回答1: Welcome to the framework! Actually the routing in Ionic is powered by ui-router. You should probably check out this previous SO question to find a couple of different ways

Angular ui-router - how to access parameters in nested, named view, passed from the parent template?

依然范特西╮ 提交于 2019-12-17 05:39:30
问题 Hi I am trying to access a parameter in the controller "ViewWorklogCrtl" while using ui-router and running into difficulty. Basically, my parent template contains: a(ui-sref="instance-ticket.worklog({id:{{ticket.testnum}}})") show and then further down the page: section(ui-view="top-section") Then in my app.js, containing client-side routing info in short I have: $stateProvider .state('instance-ticket', { url: '/ticket/:instanceID', templateUrl: 'partials/instance-ticket', controller:

Otherwise on StateProvider

蓝咒 提交于 2019-12-17 04:52:10
问题 Using angular-ui-router, How can I use the otherwise method on $stateProvider or how can I use it at all ? 回答1: You can't use only $stateProvider . You need to inject $urlRouterProvider and create a code similar to: $urlRouterProvider.otherwise('/otherwise'); The /otherwise url must be defined on a state as usual: $stateProvider .state("otherwise", { url : '/otherwise'...}) See this link where ksperling explains 回答2: You can with $stateProvider using the catch all syntax ( "*path" ). You just

angular-ui-router with requirejs, lazy loading of controller

怎甘沉沦 提交于 2019-12-17 03:39:33
问题 Could you help me to understand how to load controller in the example below before the view? It looks like the view is loaded just immediately while the controller is not loaded yet. //app.js $stateProvider.state('index', { url: "/", views: { "topMenu": { templateUrl: "/Home/TopMenu", controller: function($scope, $injector) { require(['controllers/top-menu-controller'], function(module) { $injector.invoke(module, this, { '$scope': $scope }); }); } } } }); //top-menu-controller.js define(['app

angular-ui-router with requirejs, lazy loading of controller

ぐ巨炮叔叔 提交于 2019-12-17 03:38:33
问题 Could you help me to understand how to load controller in the example below before the view? It looks like the view is loaded just immediately while the controller is not loaded yet. //app.js $stateProvider.state('index', { url: "/", views: { "topMenu": { templateUrl: "/Home/TopMenu", controller: function($scope, $injector) { require(['controllers/top-menu-controller'], function(module) { $injector.invoke(module, this, { '$scope': $scope }); }); } } } }); //top-menu-controller.js define(['app

Using $window or $location to Redirect in AngularJS

三世轮回 提交于 2019-12-17 03:34:35
问题 The app I am working on contains various states (using ui-router), where some states require you to be logged in, others are publicly available. I have created a method that validly checks whether a user is logged in, what I am currently having issues with is actually redirecting to our login-page when necessary. It should be noted that the login page is not currently placed within the AngularJS app. app.run(function ($rootScope, $location, $window) { $rootScope.$on('$stateChangeStart',

How not to change url when show 404 error page with ui-router

本秂侑毒 提交于 2019-12-17 02:31:58
问题 I want to show 404 error page, but also I want to save wrong url in location. If I'll do something like that: $urlRouterProvider.otherwise('404'); $stateProvider .state('404', { url: '/404', template: error404Template }); url will change to /404 . How I can show error message on wrong urls without changing actual url? 回答1: There is solution for this scenario. We'd use 1) one ui-router native feature and 2) one configuration setting. A working example could be observed here. 1) A native