angular-ui-router

$stateChangeStart run before getting data from Rest API

老子叫甜甜 提交于 2019-12-10 18:37:22
问题 I'm tried to do user login authentication, I've made a service named AuthService with a method isAuthenticated in which I make a call to API to cross check the user is logged in or not (Also I'll user the user role in it later), and then I call this service in $rootScope.$on but its not wait until my service get data from API, Here is my app.js var app = angular.module('myApp', ['ngRoute', 'ui.router', 'ngAnimate', 'toaster', 'ui.bootstrap']); app.config(['$routeProvider', '$locationProvider'

AngularJS + UI-Router - Manually Type URLs in HTML5 Mode without HashBang

人盡茶涼 提交于 2019-12-10 18:13:47
问题 I am currently using AngularJS with UI-Router for state management and express on the back-end. I currently have hash bang mode enabled and have been trying to find a solution that allows you type URL's without the hash bang manually in the address bar. So for example instead of typing: www.mysite.com/#!/page1 I want to able to type www.mysite.com/page1 I have tried by enable html5Mode: $locationProvider.html5Mode(true) .hashPrefix('!'); But it still doesn't work. With the above change,

AngularJS reloadOnSearch not working

☆樱花仙子☆ 提交于 2019-12-10 18:06:07
问题 After performing a search and navigating away i want the user to be able to return to the search page (by hitting back in the browser) and retain the current search parameters. I've come to realize that in order to do this, the pages url must be updated to contain data about the page. With research i found i can update the location using $location and force the page NOT to reload when a change is made by using reloadOnSearch in the routes. However, for some reason when i change the search

Provide ui-router resolved resources without injecting directly into controller

十年热恋 提交于 2019-12-10 17:49:44
问题 I'm working on an angular 1.5 app that makes heavy use of ui-router. We define our states like this: $stateProvider .state('jobs', { url: '/jobs', template: '<ut-jobs></ut-jobs>', }); Notice that the template for this page is a simple angular directive rather than a template string (or templateUrl ) with a separate controller. Our directive's controllers are defined inline, like this: angular.directive('utJobs', () => { return { templateUrl: 'jobs.html', controllerAs: 'jobs', controller: [()

ionic how to add blank page as home page of the app?

扶醉桌前 提交于 2019-12-10 17:39:51
问题 I would like to add new page into default ionic app with tabbed menu and display this page as the default page of the app. Here is how I tried to do that: I added new state into app.js .state('home', { url: '/home', views: { 'home': { templateUrl: 'templates/home.html', controller: 'HomeCtrl' } } }) and set default router to home page $urlRouterProvider.otherwise('/home'); And template file: <ion-view title="Home"> <ion-content class="padding"> <h1>Home page</h1> </ion-content> </ion-view>

Angular-ui State - Multiple views not seeing my resolve data

≯℡__Kan透↙ 提交于 2019-12-10 17:33:36
问题 For some reason, my resolvedData is not seeing by controllers when using multiple named views (angular-ui ui-router). Has anyone faced this issue? $stateProvider .state('page',{ abstract: true, templateUrl: ..., controller: abstractController }) .state('page.index', url: '/page', resolve : { resolvedData: function(CONSTANTS){ return CONSTANTS.data;} }, views: { home: {templateUrl: ..., controller: function(resolvedData){ .... } }, list: {templateUrl: ..., controller: function(resolvedData){ .

configure sails server to work with html5Mode?

霸气de小男生 提交于 2019-12-10 17:14:43
问题 I have an angular-sails app where I want to remove the hash from urls I added this to my client app.config $locationProvider.html5Mode(true); and the routing works until I refresh the page. navigating to http://localhost:1337/about works. I refresh and get { "status": 404 } from sails server. How do I configure sails to work with angularjs html5Mode? 回答1: To use HTML5Mode you need your server setup to only provide the your root (or "index.html") file. "web.com/index.html". In my opinion this

Conditionally navigate to state with angular ui-router

那年仲夏 提交于 2019-12-10 17:07:38
问题 Currently, we have a 'Portfolio' tool in beta. Once a user logs in to the main app, if they have been given access to the beta, they can navigate to the Portfolio tool directly, without any additional login. If not, they should be redirected to a Portfolio login page (state is called portfolio.login) where they can login or contact support/sales etc. Right now I have the check in the resolve block, however $state.go('portfolio.login') seems to fetch the right partials, but doesn't render them

Conditional Page Display when application opens for the first time

北战南征 提交于 2019-12-10 16:35:17
问题 Hi I am just starting to learn angular && angular-ui-router and am trying to figure out how to determine when the app is opened for the first time to send the user to the login page or home page. This is what i have so far: codeArtApp.config(function($stateProvider, $urlRouterProvider){ $stateProvider .state('login',{ url : '/login', templateUrl:'App/scripts/login/loginView.html', controller: 'loginCtrl' }) .state('profile', { url : '/profile', templateUrl:'App/scripts/login/loginView.html',

Ui-router 1.0.0.beta1 $transitions.onSuccess from $rootScope.on('$stateSuccess',

南笙酒味 提交于 2019-12-10 16:33:14
问题 In my AngularJS (v. 1.5.x), I'm converting my controller-based states to component-based states with ui-router 1.0.0 (currently in beta 1). I'm having troubles catching state changes, that where previously caught with $rootScope.on('$stateSuccess', ... . As far as I can tell, I am doing what described in the docs, and in this SO question, therefore I am wondering if I am missing something or if this is a bug of the beta 1 release. I have not converted all controllers yet, only few. The