1
I am trying to make a Modal to edit my data, using Angularjs and Laravel as backend, but when I call a function in my ng-Ubmit(), it is not invoked.
This is my modal
<div class="modal fade" id="mymodal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form ng-submit="salvar()">
total:<input type="" ng-model="editar.total" name="total">
total:<input type="" ng-model="editar.quantidade_produtos" name="quantidade_produtos">
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" type="submit" class="btn btn-primary">Save changes</button>
</div>
</form>
</div>
</div>
</div>
</div>
And this is my code
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope, $http) {
$scope.editar = function(data){
$scope.modal = data;
$('#mymodal').modal('show');
}
$scope.salvar = function(){
$scope.editar = {}
$scope.d = $scope.modal.id;
console.log($scope.editar);
}
)};
Mixing jQuery with Angular? The change of this give m* is too big!
– Wallace Maxters
If you are using Angular Bootstrap, I advise using the
ui-bootstrap
for that reason.– Wallace Maxters
I would guess that, after the completion of the modal opening, you would have to call
$scope.$apply()
, since jQuery would run outside the Angular "cycle".– Wallace Maxters