So this may be a dumb mistake but I have an angularJs application and I have ui-router changing the states. I am able to navigate to the different pages by ui-sref
and $state.go()
but for some reason if I type the url directly into the browser I get back the error cannot GET ...
. I have no clue why, but here is the config code and a state setup:
App Config:
.config(function ( $urlRouterProvider, $locationProvider) {
$locationProvider.html5Mode(true).hashPrefix('!');
$urlRouterProvider.otherwise('/');
});
Items Page component/controller/state config:
(function(){
'use strict';
angular.module('app')
.component("itemPage",{
templateUrl: 'app/itemPage/itemPage.html',
controller: itemPageCtrl
})
.config(['$stateProvider',function ($stateProvider) {
$stateProvider
.state('item', {
url: '/item',
template: '<item-page></item-page>'
});
}]);
function itemPageCtrl(){
var ctrl = this;
}
})();
Just to reiterate, if I am the main page of my site and I click a button I can get to items page with ui-sref or $state.go()
but if I try to put the url directly in localhost:9000/item
or if I am already on the page and click refresh it gives the cannot GET /item
message.
Any help will be greatly appreciated and I can give more code if needed. Thank you.