angular-ui-router

Angular 2 - Pass parameters to Route

青春壹個敷衍的年華 提交于 2019-12-18 03:55:34
问题 I have a <a> tag like below, <a [routerLink]="[/Person']">Person</a> So I want to pass the person.id to this /Person router. How can I pass it & handle it on @RouteConfig like params in Angular 1 回答1: Pass to router link: <a [routerLink]="['/Person', person.id]">Person</a> Handle in component: this.route.params.subscribe( (params: Params) => { this.id = params['id']; } ); Second way: this.route.params.forEach( (params: Params) => { this.id = params['id']; } ); In this example you have to

angularjs ui-router default child state and ui-sref

二次信任 提交于 2019-12-17 22:49:09
问题 I have the following states in my ui-router state provider: $urlRouterProvider.when('/parent', '/parent/child'); $stateProvider.state('parent', { url: "/parent", abstract: true }); $stateProvider.state('parent.child', { url: "/child" }); Which follows the best practice for having a default child state as explained here in the ui-router docs. However, when I now include a link in my document somewhere referencing parent with ui-sref such as <a ui-sref="parent">Link</a> I always get an error

Angular-ui.router: Update URL without view refresh

点点圈 提交于 2019-12-17 22:46:06
问题 I have an Angular SPA that presents a variety of recommendation lists, and a Google Map of locations, based on different cuts of some restaurant data (see m.amsterdamfoodie.nl). I want each of these lists to have their own URL. In order for Google to crawl the different lists I use <a> tags for the offcanvas navigation. At present the <a> tag causes a view refresh, which is very noticeable with the map. I can prevent this using ng-click and $event.preventDefault() (see code snippets below),

Angular ui-router get asynchronous data with resolve

℡╲_俬逩灬. 提交于 2019-12-17 21:47:44
问题 I want to display a form with data corresponding to the edited item. I use ui-router for routing. I defined a state: myapp.config(function($stateProvider) { $stateProvider. .state('layout.propertyedit', { url: "/properties/:propertyId", views : { "contentView@": { templateUrl : 'partials/content2.html', controller: 'PropertyController' } } }); In PropertyController , I want to set $scope.property with data coming from the following call (Google Cloud Endpoints): gapi.client.realestate.get

what is the purpose of use abstract state?

流过昼夜 提交于 2019-12-17 20:16:26
问题 I am working on my tutorial AngularUI project. I read all about states, nested states and abstract states. The problem is that I can't understand why and when I should use abstract state? 回答1: Abstract state does mean the state that you wrote can't be accessible directly. Abstract states still need their own for their children to plug into. It gets called when we load its child's state. You can use abstract state to define some initial pattern of your page, suppose you can take an example of

Angular ui-router: Can you change state without changing URL?

我是研究僧i 提交于 2019-12-17 19:08:02
问题 The multiple nested views functionality of the ui-router is very nice - you can easily jump from one state of your app to another. Sometimes you might want to change the URL, but sometimes not. I feel like the concept of state should be separate/optional from routing . Here's a plunker that shows what I mean. This is a fork of one of the plunkers in the ui-router documentation, with 2 minor changes noted below: .state('route1', { url: "/route", // <---- URL IS SHARED WITH ROUTE2 views: {

AngularJS change route by ng-click using ui-router

拥有回忆 提交于 2019-12-17 19:07:56
问题 How can I change the route.state using ng-click instead of a link applying ui-sref. I've tried this: <button ng-click="selectDir(file.fullPath)">set</button> with $scope.selectDir = function(location) { options.storageLocation = location; $route.current = 'recorder.options'; } But it doesn't work. Any ideas? 回答1: Check out the ui-router documentation wiki. The best solution is to use $state.go() . e.g., $state.go('recorder.options') Here's the link to the specific function in the

Lazy load template and controller in angular UI-Router

左心房为你撑大大i 提交于 2019-12-17 18:52:52
问题 I am attempting to lazy load a controller and template in my UI-Router router.js file, but am having difficulty with the template. The controller loads properly, but after that is loaded, we must load the template and this is where things go wrong. After ocLazyLoad loads the controller, we resolve an Angular promise which is also included in the templateProvider. The issue is instead of returning the promise (templateDeferred.promise) after the file is done loading, the promise is returned as

ui router - nested views with shared controller

℡╲_俬逩灬. 提交于 2019-12-17 17:37:14
问题 I have an abstract parent view that is meant to share a controller with its nested views. .state('edit', { abstract: true, url: '/home/edit/:id', templateUrl: 'app/templates/editView.html', controller: 'editController' }) .state('edit.details', { url: '/details', templateUrl: 'app/templates/editDetailsView.html' }) .state('edit.info', { url: '/info', templateUrl: 'app/templates/editInfoView.html' }) The routing works as expected. The problem is that when I update a $scope variable from one of

(Angular-ui-router) Show loading animation during resolve process

一曲冷凌霜 提交于 2019-12-17 17:24:08
问题 This is a two part question: I am using the resolve property inside $stateProvider.state() to grab certain server data before loading the controller. How would I go about getting a loading animation to show during this process? I have child states that also utilise the resolve property. The problem is that ui-router seems to want to finalise all resolves before loading any controller. Is there any way I can get the parent controllers to load once their resolves have been resolved, without