Already I’m stuck on this. Everything from the tutorials works but when I put in my own link to a signup page I get a 404…?
EDIT: tried changing it to ui-sref
login.html:
<ion-view view-title="Sign-In"> <ion-content class="padding"> <div class="list list-inset"> <label class="item item-input"> <input type="text" placeholder="E-mail" ng-model="data.email"> </label> <label class="item item-input"> <input type="password" placeholder="Password" ng-model="data.password"> </label> </div> <button class="button button-block button-positive" ng-click="login(data)">Login</button> <a ui-sref="signup" style="margin-left: 35%">Sign-up here!</a> </ion-content> </ion-view>
app.js:
`angular.module(‘starter’, [‘ionic’, ‘ngMockE2E’, ‘ionic.cloud’])
.config(function ($stateProvider, $urlRouterProvider, USER_ROLES, $ionicCloudProvider) {
$ionicCloudProvider.init({
"core": {
"app_id": "e91d92e1"
}
});
$stateProvider
.state('login', {
url: '/login',
templateUrl: 'templates/login.html',
controller: 'LoginCtrl'
})
.state('signup', {
url: '/signup',
templateUrl: 'templates/signup.html',
controller: 'SignupCtrl'
})
.state('main', {
url: '/',
abstract: true,
templateUrl: 'templates/main.html'
})
.state('main.dash', {
url: 'main/dash',
views: {
'dash-tab': {
templateUrl: 'templates/dashboard.html',
controller: 'DashCtrl'
}
}
})
.state('main.admin', {
url: 'main/admin',
views: {
'admin-tab': {
templateUrl: 'templates/admin.html'
}
},
data: {
authorizedRoles: [USER_ROLES.admin]
}
})
.state('main.public', {
url: 'main/public',
views: {
'public-tab': {
templateUrl: 'templates/public.html'
}
}
});
$urlRouterProvider.otherwise(function ($injector, $location) {
var $state = $injector.get("$state");
$state.go("main.dash");
});
})
.run(function ($ionicPlatform) {
$ionicPlatform.ready(function () {
if (window.cordova && window.cordova.plugins.Keyboard) {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
// Don't remove this line unless you know what you are doing. It stops the viewport
// from snapping when text inputs are focused. Ionic handles this internally for
// a much nicer keyboard experience.
cordova.plugins.Keyboard.disableScroll(true);
}
if (window.StatusBar) {
StatusBar.styleDefault();
}
})
})
.run(function ($httpBackend) {
$httpBackend.whenGET('http://localhost:8100/valid')
.respond({message: 'This is my valid response!'});
$httpBackend.whenGET('http://localhost:8100/notauthenticated')
.respond(401, {message: "Not Authenticated"});
$httpBackend.whenGET('http://localhost:8100/notauthorized')
.respond(403, {message: "Not Authorized"});
$httpBackend.whenGET(/templates\/\w+.*/).passThrough();
})
.run(function ($rootScope, $state, AuthService, AUTH_EVENTS) {
$rootScope.$on('$stateChangeStart', function (event, next, nextParams, fromState) {
if ('data' in next && 'authorizedRoles' in next.data) {
var authorizedRoles = next.data.authorizedRoles;
if (!AuthService.isAuthorized(authorizedRoles)) {
event.preventDefault();
$state.go($state.current, {}, {reload: true});
$rootScope.$broadcast(AUTH_EVENTS.notAuthorized);
}
}
if (!AuthService.isAuthenticated()) {
if (next.name !== 'login') {
event.preventDefault();
$state.go('login');
}
}
});
});
`
I click and nothing happens.
EDIT; I just realised that it’s probably because of my authentication. How do I make an exception for the signup page like?