I got no error in my console, but my ng-submit is just not triggering. I debug by putting something in my controller, it did trigger, means it's not the problem of my controller not loading.. Below is my source code
(function() {
angular.module('MyApp')
.controller('SignupCtrl', SignupCtrl);
SignupCtrl.$inject = ['$scope', '$rootScope', '$location', '$window', '$auth'];
function SignupCtrl($scope, $rootScope, $location, $window, $auth) {
console.log('hello') // triggered
var ctrl = this;
ctrl.signup = signup;
function signup() {
console.log('trigger') // nope??
}
}
});
View
<form ng-submit="signup()">
<div class="form-group">
<label for="name">First Name</label>
<input required type="text" name="fname" id="fname" placeholder="First Name" class="form-control" ng-model="user.fname" autofocus>
</div>
<button type="submit" class="btn btn-success">Sign up</button>
</form>
SignupCtrl as vmor something like that?$scopebut declared your view as if you are using$scope. The controller is using theController Assyntax, i.e.ng-controller = "SignupCtrl as ctrl", so you would needng-submit="ctrl.signup()"and something similar with yourng-modelitems.