sahat / megaboilerplate

Handcrafted starter projects, optimized for simplicity and ease of use.
MIT License
3.83k stars 257 forks source link

angularjs ng-submit is not working #175

Open eldyvoon opened 8 years ago

eldyvoon commented 8 years ago

I use angularjs and I think something is wrong with the controller, https://github.com/eldyvoon/megaboiletplate-angular-node/blob/master/app/controllers/login.js

line 16 will not be triggered when I try to trigger the ng-submit button.

thekage91 commented 8 years ago

I had the same problem The problem is not ng-submit, but the fact that all controllers use this keyword inside instead of $scope and in the definition of the router all controllers don't use the controllerAs syntax that would allow the use of keyword this instead of $scope.

For resolve: In the app/app.js uses controllerAs syntax for all controllers, like this:

.when('/login', { templateUrl: 'partials/login.html', controller: 'LoginCtrl', controlleAs: 'login', resolve: { skipIfAuthenticated: skipIfAuthenticated } })

and in the all views concatenate to all function/variable/ecc the keyword that you used in the controllerAs, like this: `

Log In
    <div class="form-group">
      <label for="email">Email</label>`

This is the best solution, but you can replace keyword ctrl in all controllers with $scope and this also solves the problem. This problema is a bug, i open new issue to report it.