angular-ui-router

angular ui-router: get $state info of toState in resolve

时间秒杀一切 提交于 2019-12-18 10:27:38
问题 Update : this should be possible in angular-ui-router as of 1.0.0alpha0 . See the release notes https://github.com/angular-ui/ui-router/releases/tag/1.0.0alpha0 and the issue https://github.com/angular-ui/ui-router/issues/1018 I created. I would like to access the state's name and other attributes the app is navigating to using angular ui-router when working on the resolve. The reason: I want load some user data (including their access rights) asynchronously before allowing the app the enter

Apply loading spinner during ui-router resolve

谁说我不能喝 提交于 2019-12-18 09:54:48
问题 resolve property of $routeProvider allows to execute some jobs BEFORE corresponding view is rendered. What if I want to display a spinner while those jobs are executed in order to increase user experience? Indeed, otherwise the user would feel the application has been blocked since no view elements were displayed for some milliseconds > 600 for instance. Of course, there was the way to define a global div element out of the current view to display in order to display the spinner thanks to the

Html5Mode - refreshing the angularjs page issue

假装没事ソ 提交于 2019-12-18 09:47:50
问题 I am working on an angularJS app, which has URLs in the format (in dev) - http://localhost:6001/#/home/index http://localhost:6001/#/content/index As this app, will also be available on desktop browser, I wanted the URLs to be without '#', so I added this in my app's config section - $locationProvider.html5Mode(true); Which works fine and URLs don't show '#'. But there is a problem now. On refreshing a particular page in browser, now I get this error - Cannot GET /home/index Are there any

Resolve not called the second time

被刻印的时光 ゝ 提交于 2019-12-18 09:31:53
问题 I have some routes defined like this : $stateProvider .state('app', { url: '/', abstract: true, views: { 'menuContent': { templateUrl: 'templates/home.html' } } }) .state('app.restricted', { url: '/restricted', views: { 'content': { templateUrl: 'templates/restricted/restricted-dashboard.html', controller: 'RestrictedController as vmRestricted' } }, resolve: { isGranted: 'isGranted' } }) .state('app.restricted.pending', { url: '/pending', views: { 'tabsView': { templateUrl: 'templates

angular ui-router resolve for parent state

左心房为你撑大大i 提交于 2019-12-18 07:11:46
问题 In my parent state I have a resolve . Currently, I do not inject the resolve key in any child state. I assumed that my child state would not wait for this resolve/promise to be resolved. But when I set a timeout, I can see my child state does wait. Is this correct behaviour? .config(function ($stateProvider, $urlRouterProvider, STATES) { $stateProvider .state(STATES.ROOT, { abstract: true, template:'<div ui-view=""></div>', resolve: { UserService: 'UserService', userDetails: function

Angular ui router ui-sref-active on parent

穿精又带淫゛_ 提交于 2019-12-18 06:25:45
问题 I have one parent state and many childs states. If I want the ui-sref-active on the parent to work when I am on one of the child I need to do this "hack": $scope.isActive = function() { return $state.includes('playLotteries.Index') || $state.includes('playLotteries.Group') || $state.includes('playLotteries.hunter'); } This is very ugly way and I have many children so its not seems like good solution. Anyone have another solution for this problem? 回答1: You can check parent state only instead

Webpack 2 and Angular 1: exporting and import modules

无人久伴 提交于 2019-12-18 05:45:24
问题 Hope to get some clarification on why the following doesn't work as expected, hopefully, it's something easy I may have overlooked. Without Webpack the current implementation works as expected. Ideally, would like to keep current implementation, I feel registering the component/controller/etc should be done in its own file and just point to the relative module. But if this isn't best practice I'd also like to see another suggestion. File root.module is where I define the root module and then

Injecting required dependencies with ng-controller

空扰寡人 提交于 2019-12-18 04:22:03
问题 Using ui.router, we have a controller for a state: controller('widget', function($repository, $stateParams){ $scope.widget = $repository.get($stateParams.id); }) registered with: .state('widget', controller: 'widget', template: '/widgetTemplate.html' We've come upon a case where we like to reuse this controller as part of a template: <div ng-controller="widget" ng-include="/widgetTemplate.html"></div> but there doesn't appear to be an easy way to inject a mocked $stateParams object with the

Active link/tab in AngularUI Router

半世苍凉 提交于 2019-12-18 04:14:10
问题 I'm using AngularUI Router and I'm trying to have nested/children links. All works fine but how do I have selected/active link in Contact tab? Basically, I need to be able to have selected/active contact one link when the Contact page is loaded. Currently it does not read for some reason the controlleroneCtrl unless I click on the link contact one. angular .module ('myApp', ['ui.router' ]) .config (['$urlRouterProvider', '$stateProvider', function ($urlRouterProvider, $stateProvider) {

ANGULAR-UI-ROUTER: Resolve state from URL

此生再无相见时 提交于 2019-12-18 04:08:29
问题 I'm making an app with dynamical states, and sometimes I need to resolve the state name from the url. e.g.: I have /dashboard/user/12268 and I need to get the state 'dashboard.user' . Is there any way to do this with the tools given by ui-router ? I can't find out how to do this right now... I'm making an app with dynamic module loading with requireJS. At first time there is no problem because user is sent to login state. After login, I use require to load only the states the user has access