angular-ui-router

Resolve using UI Router and pass to a component's controller

别等时光非礼了梦想. 提交于 2019-12-10 13:23:21
问题 How do I resolve a variable with UI Router when I am using a component. This is the route: $stateProvider .state('route', { url: '/route', template: '<my-component user="user"></my-component>', resolve: { user: (Auth) => { return Auth.getCurrentUser().$promise; } } }) This is the component: (function () { class BookingListComponent { constructor(user) { //I want to use the user here but getting the unknown provider error } } angular.module('app') .component('myComponent', { templateUrl: 'my

AngularJS multiple resolve

巧了我就是萌 提交于 2019-12-10 13:18:14
问题 This is my ui-router config for a specific route state('app.merchant', { url: '/start/merchant', views: { 'mainView': { templateUrl: "partials/start_merchant.html" } }, css: ['assets/vendor/bootstrap/dist/css/bootstrap.css','assets/css/styles.css','assets/css/plugins.css'], title: 'Buttons', resolve: { userRequired: userRequired, } resolve: loadSequence('flow','angularFileUpload','MerchantWizardCtrl') }) The problem is, the page is being displayed even though it doesn't meet the userRequired

Have parent state default to child state using ui-router

浪尽此生 提交于 2019-12-10 12:52:38
问题 I have this state structure: .state('places', { url:'/places', controller:'PlacesController', templateUrl:'views/places.html' }) .state('places.city', { url:'/:city', templateUrl:function(stateParams) { return 'views/places/'+stateParams.city+'.html'; } }); It works nicely except when the URL is simply /places without a city after it. How can I have a default value for templateUrl in the child state? I'm thinking the best way would be to set the ui-view from PlacesController , however that

ng-cloak doesn't help for angular ui-router for hiding elements while template parsing

99封情书 提交于 2019-12-10 12:43:36
问题 I'm using angular ui-router. I want to show something if <div ng-show="total > 0"> While the template is downloaded and shown immediately we can see a flicker of the div, before the controller loads $scope.total = . One would think that $scope.total is undefined in the beginning hence the div would be hidden, but I think the template isn't yet parsed, it's just shown raw. I tried using ng-cloak but it doesn't seem to help. Ngcloak is supposed to be used while angular is booting up, but I'm

Site navigation using ui-sref, how to remove ui-sref attribute when not available

自古美人都是妖i 提交于 2019-12-10 12:33:50
问题 I've setup navigation as follows, using ng-repeat, which works very well <a ui-sref="{{link.Route}}" ng-click="clickLink(link)"> <span class="title"> {{link.Text}} </span><span class="selected"></span> </a> However, my navigation items frequently have sublinks, which means the parent link isn't really a navigation link, it's just used to expand and view the sublinks. But sometime it is a link, and has no sublinks to display. The problem is for those particular cases, when there is no state

How to set up ngRepeat to generate entries stored externally?

大憨熊 提交于 2019-12-10 11:55:03
问题 I have table rows which I need to generate based on template. There should be some variables. For example persons[0].lastName should be persons[1].lastName for next row and so on. I want to store template in html file. I use angular-ui/ui-router . How to make this work? Example: <tr> <td> <div class="form-group first-name"> <label>First name</label> <input type="text" ng-class="{'input-valid': isValidField('FirstName', persons[0].firstName)}" name="firstName" class="form-control input-name"

md-tabs: setting variable for md-selected not working when calling function from inside ui-router

本秂侑毒 提交于 2019-12-10 11:50:05
问题 I have a ui-router template containing md-tabs from which some tabs are static, others are created dynamically using ng-repeat iterating through a given array of the data model. Inside those dynamically created tabs there are three buttons to do the following move tab left by one position move tab right by one position The move tab buttons call a function inside the same controller. The $index value of the currently shown tabs as well as the desired direction ( -1 for moving left, 1 for

Resolve a promise array with Angular UI Router

两盒软妹~` 提交于 2019-12-10 11:46:16
问题 I'm trying to resolve a promise array to things before hitting my controller: resolve:{ things: function($q){ var promises = []; var titles = []; var thingRef = ['a1', 'a2', 'a3']; angular.forEach(thingRefs, function(thingRef){ promises.push($firebase(ref.child('things').child(thingRef).child('title')).then(function(title){ titles.push(title); })); }); $q.all(promises).then(function(){ return titles; }); } }, What am I doing wrong here? 回答1: I think you need: return $q.all(promises).then

ui-router inside custom angular directive, make sense?

无人久伴 提交于 2019-12-10 11:34:31
问题 I'm working on an isolated scope custom directive that has a few different states. Does it make sense to use ui-router/ui-view inside this directive in order to handle the states? It's a "note widget" that lists notes. If there are no notes, it displays a message instead of the list that says they should add a note. If notes are being loaded, it shows that notes are being loaded. If a user adds a note by clicking the add I mentioned above or the + then the view is a textbox. So there is at

UI Router matching url with hash (fragment)

血红的双手。 提交于 2019-12-10 10:50:27
问题 Using UI router I need to match URLs with hash (fragment) included in it (HTML5 mode). .state('myState', { url: '/path/:id/page#:section', templateUrl: 'template.html', controller: 'MyController' }); While the setup above works when using ui-sref below.. <a ui-sref="myState({id: 1})"> ... // without hash => section == '' <a ui-sref="myState({id: 1, section: 'abc'})"> ... // section == 'abc' .. it fails when I redirect browser from other page manually by specifying the fragment in the address