angular-ui-router

How to send and retrieve parameters using $state.go toParams and $stateParams?

这一生的挚爱 提交于 2020-01-08 12:02:11
问题 I am using AngularJS v1.2.0-rc.2 with ui-router v0.2.0. I want to pass the referrer state to another state so I use the toParams of $state.go like so: $state.go('toState', {referer: $state.current.name}); According to the docs, this should populate the $stateParams on the toState controller, but it is undefined . What am I missing? I've created a plunk to demonstrate: http://plnkr.co/edit/ywEcG1 回答1: If you want to pass non-URL state, then you must not use url when setting up your state . I

Angular ui route stateparam in substate

随声附和 提交于 2020-01-07 04:51:13
问题 I have some issues with using a stateparam in a substate. This is my 'master' state .state("shop", { abstract: true, url: '/shop/:nameSlug', templateUrl: '/views/shop/index.html', controller: 'shopController', params: { nameSlug: null, } }) And this is my substate: .state('shop.payment-success', { url: '/payment-success?transactionid', templateUrl: '/views/payment-success.html', controller: 'checkoutController' }) I want to use the param 'transactionid' in my controller, but when I log it, it

UI-Router, how to get the name of the 'state' And How send it to the function That brings Template state

 ̄綄美尐妖づ 提交于 2020-01-07 03:07:07
问题 I start in angular And I want to write a function that will bring template For each state And just when need it. As the principle of "Lazy loading" And after that keep it in the cache when it's the first time I wrote this code But I have errors, and I do not know what I'm wrong, Some things I did not understand in angular so I understand the problematic in my code this is all my code : http://plnkr.co/edit/qzKJUwNImVX8EGb3ymnT?p=preview var app = angular.module('myApp', ['ui.router']); var

Angular-ui-router 0.3.2 doesn't work correct with components

只愿长相守 提交于 2020-01-07 02:56:09
问题 0.3.2 is a new version of ui-router ui-router releases I have tested it and looks like it doesn't work correct. Please take a look this example. Console output - Unknown provider: $uiRouterProvider <- $uiRouter 回答1: We just wrote a comprehensive blog post about components and ui router. It may help with both your current situation and the future upgrade to ui.router 1.0. http://blog.aviture.us.com/2017/01/03/ui-routing-to-components-in-angular.html 来源: https://stackoverflow.com/questions

How to use AngularJS UI-router capture this URL with an optional parameter?

 ̄綄美尐妖づ 提交于 2020-01-07 02:55:30
问题 I'm using AngularJD ui-router to capture my URL and send two parameters from that URL to my controller. Here are my requirements: The first parameter is a mandatory integer ( id ) The second parameter is an optional string ( slug ) The two parameters are separated by a / I want it to ignore any single trailing / Currently, I'm doing this: $stateProvider.state('mystate', { url: '/mystate/{id:int}{slug:(?:/[^/]+)?}', params: { slug: {value: null} }, templateUrl: 'partials/mystate.html',

UI-Router dynamically set parent state at runtime

ぐ巨炮叔叔 提交于 2020-01-06 19:26:33
问题 Is there any way to dynamically set the parent state of a ui-router state at runtime? I have a case where I need to set a different parent state, depending on whether or not the user is logged in. I have a service that I can use to fetch this authentication status. 来源: https://stackoverflow.com/questions/37759172/ui-router-dynamically-set-parent-state-at-runtime

Persist state when changing to another state

强颜欢笑 提交于 2020-01-06 17:08:54
问题 I want to create dynamic navigation, that i can change navigation item by state, the problem is when i change the content, the navigation is cleared out, i already tried this solution but it seems not working on my cases Here is my plunker And here is my state configuration var app = angular.module('knax', ['ui.router', 'ui.bootstrap']); app.config( function($stateProvider) { $stateProvider.state('app', { views: { '@': { templateUrl: 'layout.html' }, 'navigation-layout@app': { templateUrl:

Angular ui-router nested views - the page isn't loading when direct url is used

痴心易碎 提交于 2020-01-06 14:39:33
问题 I'm trying to access a nested view with the direct url, without navigating through links but it's not working. My config is: myApp.config(function ($stateProvider, $locationProvider) { $stateProvider .state('st1', { url: '/st1', templateUrl: 'st1.html', }) .state('st1.st2', { url: '/st2', templateUrl: 'st2.html', }) ; $locationProvider.html5Mode(true); }); st1.html: <h1>ST1</h1> <div ui-view></div> <a ui-sref="st1.st2">ST2</a> st2.html: <h2>ST2</h2> <a ui-sref="st1">ST1</a> I go directly to

ui-sref-active on an abstract state

雨燕双飞 提交于 2020-01-06 14:32:07
问题 I have these routes: .account /:email .account.home /:email .account.personal /:email/personal .account.settings /:email/settings .account is an abstract state and .account.home is the default state that it would go onto. Now if I have this link, with an ui-sref-active to add a class when it is navigated, I would do something like <a ui-sref-active='active' ui-sref='.account.home({email: account.email})'></a> the right element is set with an active class when it is clicked (which is was

Reloading only child state

元气小坏坏 提交于 2020-01-06 14:27:58
问题 I have nested UI states. I want to load only child state not the parent state. Child State : $stateProvider.state('app.test', { url: '^/test?search', controller: 'TestController', templateUrl: 'test/test.tpl.html', pageTitle: 'Tests', }); Parent State : $stateProvider.state('app', { url: '/app', abstract: true, templateUrl: 'parent/main-content.tpl.html', controller: 'ParentController' }) When I try to load only child state in test page using $state.go('.', {search: searchTerm}); It loads