0
I’m studying how to consume Webapi with Angular by this website. Everything was going well until I made this mistake:
angular.js:13550 Error: Could not resolve 'stateOne' from state ''
at Object.v.transitionTo (angular-ui-router.min.js:7)
at Object.v.go (angular-ui-router.min.js:7)
at angular-ui-router.min.js:7
at angular.js:19157
at e (angular.js:5869)
at angular.js:6145
I tried to research something like that, but I couldn’t find an explanation. From what I searched it seems that this is a problem when loading javascript files.
Follow the application module code:
// Módulo da aplicação
var AwesomeAngularMVCApp = angular.module('AwesomeAngularMVCApp', ['ui.router', 'ui.bootstrap']);
// Controllers
AwesomeAngularMVCApp.controller('LandingPageController', LandingPageController);
AwesomeAngularMVCApp.controller('LoginController', LoginController);
AwesomeAngularMVCApp.controller('RegisterController', RegisterController);
// Factories
AwesomeAngularMVCApp.factory('LoginFactory', LoginFactory);
AwesomeAngularMVCApp.factory('RegistrationFactory', RegistrationFactory);
AwesomeAngularMVCApp.factory('AuthHttpResponseInterceptor', AuthHttpResponseInterceptor);
var configFunction = function ($stateProvider, $httpProvider, $locationProvider) {
$locationProvider.hashPrefix('!').html5Mode(true);
$stateProvider
.state('stateOne', {
url: '/stateOne?donuts',
views: {
"containerOne": {
templateUrl: '/routesDemo/one'
},
"containerTwo": {
templateUrl: function (params) {
return '/routesDemo/two?donuts=' + params.donuts;
}
}
}
})
.state('stateTwo', {
url: '/stateTwo',
views: {
"containerOne": {
templateUrl: '/routesDemo/one'
},
"containerTwo": {
templateUrl: '/routesDemo/three'
}
}
})
.state('stateThree', {
url: '/stateThree?donuts',
views: {
"containerOne": {
templateUrl: function (params) {
return '/routesDemo/two?donuts=' + params.donuts;
}
},
"containerTwo": {
templateUrl: '/routesDemo/three'
}
}
})
.state('loginRegister', {
url: '/loginRegister?returnUrl',
views: {
"containerOne": {
templateUrl: '/Account/Login',
controller: LoginController
},
"containerTwo": {
templateUrl: '/Account/Register',
controller: RegisterController
}
}
});
$httpProvider.interceptors.push('AuthHttpResponseInterceptor');
}
configFunction.$inject = ['$stateProvider', '$httpProvider', '$locationProvider'];
Follow the controller code:
var LandingPageController = function ($scope) {
$scope.models = {
helloAngular: 'Eu consigo!'
};
$scope.product = {
produto: 'Rotas'
};
$scope.navbarProperties = {
isCollapsed: true
};
}
/* The $inject property of every controller (and pretty much every other type of object in Angular)
* needs to be a string array equal to the controllers arguments, only as strings
**/
LandingPageController.$inject = ['$scope'];
I would be very grateful for any explanation on how to resolve this mistake.
The state
stateOne
not configured. It may be that it is being set in a file . js that has not been loaded.– OnoSendai
@Onosendai How do I solve this?
– Iago Frota
Post your code. It’s hard to deduce the real cause just by the error message.
– OnoSendai