javascript - adding array to other form controller in angular -


i have event.controller.js , event.view.html

in controller have event , guests, event form of multiple models , guests 1 model array can pass more values too.

i have localstorage events save form guests array doesn't passed form because seperated though they're part of same controller.

 function eventcontroller($location, userservice, eventservice, $rootscope, $http, flashservice) {     var vm = this;    vm.guests = [];       vm.addguest = function () {         vm.guests.push(vm.newguest);     }      vm.removeguest = function (guest) {         var index = vm.guests.indexof(guest);         vm.guests.splice(index, 1);     }      vm.event = event;       function event() {         vm.dataloading = true;         eventservice.create(vm.events)             .then(function (response) {                 if (response.success) {                     flashservice.success('event created successful', true);                     $location.path('/events');                 } else {                     flashservice.error(response.message);                     vm.dataloading = false;                 }             });     } 

my event.view.html looks

  <form name="form" ng-submit="vm.event()" role="form">             <!--all event input fields-->     <div class="form-actions">     <button type="submit" ng-disabled="form.$invalid || vm.dataloading" class="btn btn-primary">create</button>     <a href="#/login" class="btn btn-link">cancel</a>    </div>   </form>   <form name="form" ng-submit="vm.guest()" role="form">    <div class="form-actions">     <button type="submit" ng-disabled="guestform.$invalid || vm.dataloading" ng-click="vm.addguest()" class="btn btn-primary">add guest</button>    </div>     <div ng-repeat="guest in vm.guests track $index" class="col-sm-6">        {{guest}} - <a class="btn" ng-click="vm.removeguest(guest)">delete</a>     </div>   </form> 

different forms submit same eventcontroller different model namespaces, how vm.events.guest array equal vm.guests after add vm.addguest() method?


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -