This question asked already but that not solve my issue.
Am trying to pass checkbox
value to controller but i got undefined
message. Am beginner in Angularjs
.
This is my HTML
code:
<form class="form-horizontal" name="addForm" novalidate ng-submit="addData(addForm)">
<div class="form-group">
<div class="col-sm-3" ng-repeat="directories in formData.getMainDirectories">
<input type="checkbox" ng-model="directories.main_directories_id.selected" value=""><span> </span>
</div>
</div>
<button type="submit" class="btn btn-primary btn-md" button-spinner="loading" ng-disabled="loading">Submit</button>
</form>
My .js
code:
$scope.addData = function(form)
{
$scope.errors = [];
alert(form.main_directories_id); // alert here
if(form.$valid)
{
$rootScope.loading = true;
webServices.upload('create', $scope.formData).then(function(getData) {
$rootScope.loading = false;
if (getData.status == 200) {
$sessionStorage.successmessage = getData.data.message;
localStorage.directory = '';
$scope.goback();
} else if (getData.status == 401) {
$scope.errors = utility.getError(getData.data.message);
$scope.showerrors();
} else {
$rootScope.$emit("showerror", getData);
}
});
}
}
$scope.getMainDirectories = function()
{
webServices.get('getMainDirectories').then(function(getData)
{
$rootScope.loading = false;
if (getData.status == 200)
{
$scope.formData.getMainDirectories = getData.data;
} else {
$rootScope.$emit("showerror", getData);
}
//console.log(getData.data);
});
}
Aucun commentaire:
Enregistrer un commentaire