arrays - Multiple controllers in a meanjs form, submitting empty values -



arrays - Multiple controllers in a meanjs form, submitting empty values -

i calling values database , putting them in select box in form, however, whenever click on submit, submits empty value, thinking because using multiple controllers in form, have gathered, have scope in controllers, have been unable that

attached re-create of create-view file, highlited portions multiple controllers. please how create work? give thanks much

<section data-ng-controller="candidatescontroller"> <div class="page-header"> <h1>new candidate</h1> </div> <div class="col-md-12"> <form class="form-horizontal" data-ng-submit="create()" novalidate> <fieldset> <div class="form-group"> <label class="control-label" for="name">name</label> <div class="controls"> <input type="text" data-ng-model="name" id="name" class="form-control" placeholder="name" required> </div> </div> <div class="form-group"> <label class="control-label" for="vision">vision</label> <div class="controls"> <textarea data-ng-model="vision" id="vision" class="form-control"></textarea> </div> </div> <div class="form-group"> <label class="control-label" for="dob">date of birth</label> <div class="controls"> <input type="date" data-ng-model="dob" id="dob" class="form-control" required> </div> </div> <div class="form-group"> <label class="control-label" for="post">post</label> <div class="controls"> <select data-ng-model="post" id="post" class="form-control"> <option value="presidential">presidential</option> <option value="provincial">provincial</option> <option value="municipal">municipal</option> </select> </div> </div> <div class="form-group"> <label class="control-label" for="province">province</label> <div class="controls"> <select data-ng-model="province" id="province" class="form-control"> <option value="gauteng">gauteng</option> <option value="free-state">free-state</option> <option value="kwazulu-natal">kwazulu-natal</option> </select> </div> </div> <div class="form-group"> <label class="control-label" for="municipal">municipal</label> <div class="controls"> <input type="text" data-ng-model="municipal" id="municipal" class="form-control" placeholder="municipal" required> </div> </div> <div class="form-group"> <label class="control-label" for="party">party</label> <div class="controls"> <section data-ng-controller="partiescontroller" data-ng-init="find()"> <select data-ng-model="party" class="form-control" ng-options="party.name party in parties track party.name"> </select> </section> </div> </div> <div class="form-group"> <input type="submit" class="btn btn-default"> </div> <div data-ng-show="error" class="text-danger"> <strong data-ng-bind="error"></strong> </div> </fieldset> </form> </div> </section>

the candidate controller code

'use strict'; //candidates controller angular.module('candidates').controller('candidatescontroller', ['$scope', '$stateparams', '$location', 'authentication', 'candidates', function($scope, $stateparams, $location, authentication, candidates ) { $scope.authentication = authentication; // create new candidate $scope.create = function() { // create new candidate object var candidate = new candidates ({ name: this.name, vision: this.vision, dob: this.dob, post: this.post, province: this.province, municipal: this.municipal, party: this.party }); // redirect after save candidate.$save(function(response) { $location.path('candidates/' + response._id); // clear form fields $scope.name = ''; }, function(errorresponse) { $scope.error = errorresponse.data.message; }); }; // remove existing candidate $scope.remove = function( candidate ) { if ( candidate ) { candidate.$remove(); (var in $scope.candidates ) { if ($scope.candidates [i] === candidate ) { $scope.candidates.splice(i, 1); } } } else { $scope.candidate.$remove(function() { $location.path('candidates'); }); } }; // update existing candidate $scope.update = function() { var candidate = $scope.candidate ; candidate.$update(function() { $location.path('candidates/' + candidate._id); }, function(errorresponse) { $scope.error = errorresponse.data.message; }); }; // find list of candidates $scope.find = function() { $scope.candidates = candidates.query(); }; // find existing candidate $scope.findone = function() { $scope.candidate = candidates.get({ candidateid: $stateparams.candidateid }); }; }

]);

arrays angularjs meanjs

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -