angularjs - How to access ng-model value in controller of popup model in angular? -


i want access ngmodel within controller, here ngmodel defines in popup input field. want access qty , name values in controller. note whole code model popup.

model code

<ion-modal-view>      <ion-header-bar>         <h1 class="title">item details</h1>     </ion-header-bar>     <ion-content padding="true">         <form ng-submit="additem()">             <div class="list list-inset">                 <label class="item item-input">                     <span class="input-label">name</span>                     <input type="text" name="name" ng-model="name">                 </label>                 <label class="item item-input">                     <span class="input-label">qty</span>                     <input type="number" name="qty" ng-model="qty">                 </label>                 <div class="padding item text-center">                     <button class="button button-dark">add cart</button>                     <a class="button  button-assertive" ng-click="closemodal()">cancel</a>                             </div>             </div>         </form>     </ion-content> </ion-modal-view> 

controller code

.controller('guestdetailsctrl', function($scope){     $scope.additem = function() {         alert($scope.name);         alert($scope.qty);     };  }); 

you try give params in function :

<ion-modal-view>  <ion-header-bar>     <h1 class="title">item details</h1> </ion-header-bar> <ion-content padding="true">     <form ng-submit="additem(params)">         <div class="list list-inset">             <label class="item item-input">                 <span class="input-label">name</span>                 <input type="text" name="name" ng-model="params.name">             </label>             <label class="item item-input">                 <span class="input-label">qty</span>                 <input type="number" name="qty" ng-model="params.qty">             </label>             <div class="padding item text-center">                 <button class="button button-dark">add cart</button>                 <a class="button  button-assertive" ng-click="closemodal()">cancel</a>                         </div>         </div>     </form> </ion-content> 

and in controller :

   .controller('guestdetailsctrl', function($scope){       $scope.additem = function(params) {           alert(params.name);           alert(params.qty);       };    }); 

Comments