javascript - Using multiple methods on one controller in AngularJS -
please need , advice. want use 2 methods on 1 controller. first method display selected rooms , second display selected pax. however, first method works, second md-select don't display array in second method. here js , html code snippet:
var app = angular.module('corewebapp', ['ngmaterial', 'ngmessages', 'nganimate']); app.controller('selectedtextcontroller', function($scope) { $scope.rooms = [1, 2, 3, 4, 5, 6, 7]; $scope.selectedroom; $scope.getselectedtext = function() { if ($scope.selectedroom !== undefined) { return $scope.selectedroom + " room(s)"; } else { return "rooms"; } }; $scope.paxes = [1, 2, 3, 4, 5]; $scope.selectedpax; $scope.getselectedpersons = function() { if ($scope.selectedpax !== undefined) { return $scope.selectedpax; } else { return "pax"; } }; });
<div> <label>rooms</label> <div layout-sm="column" layout-align="center end"> <md-select md-no-resize ng-model="selectedroom" md-selected-text="getselectedtext()"> <md-optgroup label="rooms"> <md-option ng-value="room" ng-repeat="room in rooms">{{room}} rooms</md-option> </md-optgroup> </md-select> </div> </div> <div> <label>pax</label> <div> <md-select ng-model="selectedpax" md-selected-text="getselectedpersons()" aria-label=""> <md-optgroup label="pax"> <md-option ng-value="pax" ng-repeat="pax in paxes">{{pax}}</md-option> </md-optgroup> </md-select> </div> </div>
i cannot run code test believe following
<md-optgroup label="pax">
should
<md-optgroup label="paxes">
Comments
Post a Comment