angular-ui-router

Check if user has permission to access specific states

假如想象 提交于 2019-12-10 00:48:02
问题 I use angular-permission and I want to check if user has access to specific states. My state config: $stateProvider .state('app', { url: '/', abstract: true, data: { permissions: { only: ['BASE'] } } }) Is there a method or something which I can use in controllers to determine it? // somewhere in controller if (Permission.hasAccessToState('app')) { // I want to check if user has access to state without navigating to it }; If anyone is interested, here is a corresponding discussion on github.

Nested views with nested states in AngularJS

霸气de小男生 提交于 2019-12-09 19:01:01
问题 I'm trying to make nested states, but something is wrong and I can't figure out why. I have these states in my angular app: /client (list clients) /client/:id (show client) /client/new (new client) And now, I'm trying to do: /client/:id/task (list clients tasks) /client/:id/task/new (create new task for this client) /client/:id/task/:idTask (show the client task) All the states are working, but the task states is not changing the content. My index.html with the ui-view "main" : <section id=

How to pass $stateParams from ui-router to service in resolve? [closed]

偶尔善良 提交于 2019-12-09 16:42:57
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . I have a route to retrieve a single post and a service to query my API to do so. But I need to pass parameters from the URL to the service so that I can call the API properly. I cannot wrap my head around how to do that. This is what I have come up with so far. I left out what seemed not relevant for this

AngularUI Router: pass url params to 'abstract' state while calling child state

百般思念 提交于 2019-12-09 15:39:41
问题 I want to access the url parameter($stateParam) inside a abstract state while calling a child state. I am curious to know how that can be done. Code in plunker also $stateProvider .state('contacts', { abstract: true, //my whole point is to get the id=1 here :( url: '/contacts/:id', templateUrl: function($stateParams){ console.log("Did i get the child's parameter here? " + $stateParams.id) return 'contacts' + $stateParams.id + '.html'; //this will have a ui-view in it which will render its

How to stop $interval on leaving ui-state?

∥☆過路亽.° 提交于 2019-12-09 14:32:45
问题 Angular, UI-router. Using $interval in a controller of a state like so: $scope.Timer = null; $scope.startTimer = function () { $scope.Timer = $interval($scope.Foo, 30000); }; $scope.stopTimer = function () { if (angular.isDefined($scope.Timer)) { $interval.cancel($scope.Timer); } }; The problem? The timer persists upon leaving the state. My understanding was that the $scope and the controller are essentially "destroyed" when a state is left. So, based on that, the timer should stop (Within

Access $state inside template

不打扰是莪最后的温柔 提交于 2019-12-09 11:03:23
问题 Background I create an app with a menu on the left which contains several menu items. When the user clicks on an item (or access it via an URL), I want to highlight the item (i.e. apply the class 'active' on the corresponding <li> ). Note : I handle routes with ui.router . What I tried Up to now, I try to use a ng-class directive : <div class="col-sm-3 col-md-2 sidebar"> <ul class="nav nav-sidebar"> <li ng-class="{active: current=='container.item1'}"> <a href="#/a/item1">Item 1</a> </li> <li

Can a controller inherit scope from a parent controller when using ui-router

对着背影说爱祢 提交于 2019-12-09 10:55:11
问题 I have the following: var admin = { name: 'admin', url: '/admin', views: { 'nav-sub': { templateUrl: '/Content/app/admin/partials/nav-sub.html', controller: function ($scope) { $scope.message = "hello"; } } }, controller: ['$scope', function ($scope) { $scope.message = "hello"; }] } var subject = { name: 'subject', parent: admin, url: '/subject', views: { 'grid@': { templateUrl: '/Content/app/admin/partials/grid-subject.html', controller: 'AdminGridSubjectController', } } }; I would like the

Change both state and params dynamically in ui-sref

你说的曾经没有我的故事 提交于 2019-12-09 09:14:03
问题 Using ui-router I would like to set the ui-sref directive dynamically inside an ng-repeat, like so: <a ng-repeat="step in steps" ui-sref="{{step.state(step.param)}}"></a> Where steps is an array of "state objects" each with its own state and param object: var steps = [{state: 'foo', param: {id: 'bar'}}, {...}]; That throws an interpolation error. On the other hand, passing only the state OR param dynamically works great per below: // Pass only dynamic state works great <a ng-repeat="step in

html partial is not loaded into ui-view

[亡魂溺海] 提交于 2019-12-09 04:35:33
I have posted a sample on plunker: http://plnkr.co/edit/aOOlXOUIUQTARb8D7jNR?p=preview I get no errors in my browser console. I want that when I switch the day/week/month views by pressing the according button that below the buttons the html for the view is shown. But that happens not. The reason might because the day , week and month controllers are not hit in the code whyever that is. So my question is why are the controllers not loaded or the ui-view not replaced with the real html partial. As I do not know the real cause I have to ask for both cases. 'use strict'; angular .module('dates',

Stop browser back in ui-router - angularjs

牧云@^-^@ 提交于 2019-12-09 03:58:29
Once i logged into application,if i click back button in browser it should not go back to login page again(Back button should be disable at that time). $stateProvider(function('$stateProvider'){ $stateProvider .state('login',{}) .state('app.home',{}) .state('app.contact',{}); }); From login page,im getting into app.home state,once i clicked back button it should not go for login page(Browser back button should be disable). Thanks in advance. I think that you have to deal with some basic routes and storage implementation. Take this structure as an easy example of an authentication: we have the