I need help with redirecting to a different route upon form submission using AngularJS. I keep encountering an error message that says
Cannot read property 'go' of undefined object
Here is the code for my form:
<div class="col-sm-4 col-sm-push-4 margin-top-30">
<form ng-controller="LogonController" data-ng-submit="vm.setDjName()" name="logonForm" novalidate>
<div class="form-group">
<input type="text" name="dj-name" data-ng-model="vm.djName" placeholder="Your DJ Name" class="form-control">
</div>
<button class="btn btn-primary btn-block" data-ng-click="vm.setDjName()" type="button">Login</button>
</form>
</div>
And here is my controller:
(function () {
'use strict';
angular
.module('app.controllers')
.controller('LogonController', LogonController);
LogonController.$inject = [];
function LogonController ($state) {
var vm = this;
vm.setDjName = function () {
$state.go('/video');
}
}
})();
Any suggestions on how to restructure the code to successfully execute the redirect?