I'm using Yeoman + AngularJS + Ui Router. When I`m used ng-router its possible open mobile browser (local-ip):9000 and use app, but with Ui Router I can not do the same. Should I setup something?
For eg: Run grunt server in computer. Open my browser in mobile and access my local ip:port.
Bit of code:
app.js
.config(['$locationProvider', '$urlRouterProvider', '$httpProvider',
function($locationProvider, $urlRouterProvider, $httpProvider) {
$locationProvider.html5Mode(true).hashPrefix('!');
$urlRouterProvider.otherwise('/404');
$httpProvider.interceptors.push('AuthInterceptorService');
}
.run(['$rootScope', 'AuthenticationService', '$state',
function($rootScope, AuthenticationService, $state) {
var routesThatRequireAuth = ['/dashboard'];
$rootScope.$on('$stateChangeStart',
function(event, toState) {
if (_.contains(routesThatRequireAuth, toState.url) && !AuthenticationService.isLoggedIn()) {
event.preventDefault();
$state.transitionTo('login');
} else if (toState.url === '/' && AuthenticationService.isLoggedIn()) {
event.preventDefault();
$state.transitionTo('dashboard');
}
});
}
]);
login.js
'use strict';
angular.module('App').config(['$stateProvider',
function($stateProvider) {
$stateProvider
.state('login', {
url: '/',
views: {
'': {
templateUrl: 'views/login/login.html',
controller: 'LoginCtrl'
},
'header@login': {
templateUrl: 'views/layouts/anonymous/header.html'
},
'body@login': {
templateUrl: 'views/login/body.html'
}
}
});
}
]);