angularjs - Getting the current month by default in a dropdownlist -
i working in project user on first visit can see content of current month default. if want see contents of month need select month , year dropdown list.
<div class="row" ng-show="firstvisit"> <div class="col"> <select ng-init="item1=m+1" ng-model="item1" ng-change="onchangemonth()" style="width:100%;text-align:center;"> <option style="text-indent:30%" ng-repeat="item1 in ideamonthlist" value="{{item1}}" >{{item1}}</option> </select> </div> </div> <div class="row" ng-hide="firstvisit"> <div class="col"> <select ng-model="item1" ng-change="onchangemonth()" style="width:100%;text-align:center;"> <option style="text-indent:30%" ng-repeat="item1 in ideamonthlist" value="{{item1}}" >{{item1}}</option> </select> </div> </div>
if user visited 1st time should show current month details,i able contents the month selected not coming in dropdown.
$scope.firstvisit=true; var d = new date(); var m = d.getmonth(); var ideamonth=["1","2","3","4","5","6","7","8","9","10","11","12"] $scope.ideamonthlist=ideamonth; $rootscope.monthselected=m+1; $scope.onchangemonth = function() { selectedvalue=$scope.item1; $rootscope.monthselected = selectedvalue; };
should $scope.item1 = m+1
or $scope.item1 = $rootscope.monthselected
however, dont need use $rootscope
storing month.
Comments
Post a Comment