angular-ui-router

How to test Angularjs route's resolve value on component?

China☆狼群 提交于 2019-12-23 05:10:40
问题 I'm using angular@1.5.8 and resolve some resource at the route level for one of my component. The component works as expected but my test fails now. Error PhantomJS 2.1.1 (Linux 0.0.0) module ag.expense-claim ExpenseClaimController: should load data FAILED TypeError: undefined is not an object (evaluating 'vm.attachedReceipts.results') (line 16) ExpenseClaimViewController@app/expenses/expense_claim.js:16:50 ExpenseClaimViewController@[native code] instantiate@node_modules/angular/angular.js

AngularJS ui-router application has /#!/ in the URL [duplicate]

喜你入骨 提交于 2019-12-23 04:56:31
问题 This question already has answers here : URL hash-bang (#!/) prefix instead of simple hash (#/) in Angular 1.6 (3 answers) Closed 2 years ago . I have an application with ui.router working normally, but another application the url has an "!" after "#" Ex: http://localhost:8090/dev/#!/home Why it happens? The normal should be: http://localhost:8090/dev/#/home 回答1: I suppose this happens because hashprefix is not set. $locationProvider .hashPrefix('!'); I guess you can set it to empty string

How to handle routing in MEAN application for multiple pages

一笑奈何 提交于 2019-12-23 04:55:25
问题 I want to access my admin end using the URL http://localhost:3000/users/123 for which I have the following routing using Angular UI-Router module: .state('users', { url: '/users/:id', views: { '': { templateUrl: 'partials/admin/index.html', controller: 'UserController' }, 'sidebar@users': { templateUrl: 'partials/admin/sidebar.html', controller: 'UserController' }, 'content@users': { templateUrl: 'partials/admin/content.html', controller: 'UserController' }, //other named views } }) Accessing

ui-router state resolve entries are being evaluated twice when using an optional {parameter}

僤鯓⒐⒋嵵緔 提交于 2019-12-23 04:29:25
问题 UI-Router resolve entries are reloading twice when using $state.go or ui-sref when using an optional {parameter}, and the optional parameter is not filled. .state('dashboard.loan', { url: "/loan/:type/{instanceid}", templateUrl: '/app/dashboard/views/package.html', controller: 'PackageController', controllerAs: 'packageCtrl', resolve: { UserAuth: session } }) // Resolves only once when both parameters are provided $state.go( 'dashboard.loan', { packageType: packageType, packageInstanceId:

how to implement custom routes in angular.js?

安稳与你 提交于 2019-12-23 03:06:16
问题 I've got a route: .state('home.blog', { url: "/blog", templateUrl: "blog.html", controller: "BlogController" }) And my route is localhost:3000/home/blog I would like to change it to localhost:3000/blog . I searched the Internet but I have not found any simple solution. 回答1: This is because the url part is dervied from parent. But we can explicitly set, that parent should not be used by ' ^ ': .state('home.blog', { url: "^/blog", templateUrl: "blog.html", controller: "BlogController" }) See

UI-Router : State redirecting to first child on page refresh

戏子无情 提交于 2019-12-23 02:46:36
问题 I am working on an AngularJS app using UI router with multiple named views. My app has one ui-view in index.html and states are configured as : $stateProvider .state('login', { url : '/', templateUrl : "partials/login.html", controller : "login-controller" }) .state("portal", { url :"", abstract : true, templateUrl : "partials/header.html", }) .state("portal.create-claim", { url : "/dashboard", views : { 'create-claim' : { templateUrl : "partials/create-claim.html", controller : "create-claim

$stateChangeStart event continuing after state change

懵懂的女人 提交于 2019-12-23 02:32:21
问题 I'm attempting to send the user to a specific 'closed' UI State in Angular using the following: $rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams) { // check the destination is active if(toState.data.isClosed) { // note that the 'closed' state has isClosed set to false event.preventDefault(); $state.go('closed'); } $rootScope.data = toState.data; // getting executed twice after our state transition to 'closed' $log.debug(toState); }); The issue I'm

default inactive state for ui-router-extras

纵然是瞬间 提交于 2019-12-23 02:16:10
问题 I am using ui-router-extras to support parallel state for modal windows. When an modal window is open, the "home" state become inactive, but is still visible in the background. This allows me to have deep link for each modal windows. However, I am having trouble figure out a good way to set the "default" inactive state to "home" if an user come through a modal window link. I currently define my states like this: $stateProvider .state('signup', { url: '/signup', onEnter: function($modal) {

How to correctly implement multiple views with UI Router in Angular?

情到浓时终转凉″ 提交于 2019-12-23 02:10:22
问题 I'm trying to implement a site with two main content 'panes' (imagine two columns each half the width of the page). The panes should be able to change independent of each other and have their own controllers and be able to pass data between each other (so the user can navigate through a bunch of pages on the left pane while the right pane stays the same without reloading and vice versa, and a change in the left pane can update data showing up in the right pane). I've looked through a bunch of

Replacing ui router 0.2 with 1.0.0

泪湿孤枕 提交于 2019-12-23 01:54:27
问题 I have upgraded ui-router v0.2 to 1.0.0 but I have some issues with my existing code. So I read in the official docs that $rootScope.$on('$stateChangeStart' is now replaced with $transitions.onStart({}, same with $rootScope.$on('$stateChangeSuccess' with $transitions.onSuccess({}, So far so good. But in my original code I have the following: $rootScope.$on('$stateChangeStart', function (event, toState, toParams, fromState, fromParams) { // some code here $state.go(toState.name, toParams); } I