ElenaDBA ElenaDBA - 10 months ago 78
AngularJS Question

Getting `state not defined` error when it is defined

In my angular application I want to go to another page on a click of a button. For that I use GoNext function. Below is my code that gives me

state is not defined
error. Can anyone tell me what is going on?

(function () {
angular.module("MyApp").controller("MainCtrl", ["$scope", "$state", "$http", MainCtrlFunction]);
function MainCtrlFunction($scope, $state, $http) {


$scope.GoNext = function () {



I do have a corresponding entry in my config file.

Answer Source

You've miss typed the service $state's name. It's just a confusion because you have two things named state on your code: the argument $state which is a service and the state of your aplication router; Anyways, it should look like:


Instead of: