Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
173
rated 0 times [  180] [ 7]  / answers: 1 / hits: 52944  / 10 Years ago, mon, february 17, 2014, 12:00:00

My view:



<div class=modal tabindex=-1 role=dialog ng-controller=LocationController>
<div class=modal-dialog>
<div class=modal-content>
<div class=modal-header>
<button type=button class=close ng-click=$hide()>&times;</button>
<h4 class=modal-title>
Add a Location
</h4>
</div>
<div class=modal-body>
<form class=form-horizontal role=form ng-submit=createLocation()>
<div class=form-group>
<label class=col-sm-2 control-label>Name</label>
<div class=col-sm-10>
<input type=text class=form-control placeholder=Warehouse A, Row 15, Shelf BC1, etc ng-model=name>
</div>
</div>

<div class=form-group>
<label class=col-sm-2 control-label>Type</label>
<div class=col-sm-10>
<input type=text class=form-control placeholder=warehouse, row, shelf, etc ng-model=type>
</div>
</div>

</form>
</div>
<div class=modal-footer>
<button type=submit class=btn btn-primary>Save</button>
<button type=button class=btn btn-danger ng-click=$hide()>Cancel</button>
</div>
</div>
</div>
</div>


My controller:



angular.module('mean').controller('LocationController', ['$scope', '$location', '$rootScope', 'LocationService', '$modal', '$routeParams', function ($scope, $location, $rootScope, LocationService, $modal, $routeParams) {

$scope.createLocation = function() {
alert('afds');
LocationService.create(this).then(function(response) {
console.log(response);
});
}

}]);


Yet, when I click save, I don't get the alert. Not sure what's going on there.


More From » angularjs

 Answers
3

Thanks to Matt Way's comment - turns out my save button was outside my form. Fixed


[#72482] Saturday, February 15, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tajo

Total Points: 415
Total Questions: 124
Total Answers: 103

Location: North Korea
Member since Tue, Jun 16, 2020
4 Years ago
;