-2

I need to create a format like this << April-2017 >> ,If i click on << once the result should be << March-2017 >> and if I Click >> once i Should get << April-2017 >>. How to implement this in angularJS ,Please Help me out, I am new to AngularJS.

lifeisbeautiful
  • 817
  • 1
  • 8
  • 18
  • (consider adding the javascript tag to this question) – evolutionxbox Apr 18 '17 at 09:34
  • What have you tried so far ? You need to post your code... – Lotus91 Apr 18 '17 at 09:35
  • I haven't tried , because i didn't had no idea of implementing this. @Lotus91 – lifeisbeautiful Apr 18 '17 at 09:39
  • @AravindBhatK Then start to read basic tutorials. Learn Javascript, Learn Angularjs then try to implement what you need – Weedoze Apr 18 '17 at 09:42
  • I expect either angular or one of its extensions to already have prebuilt date pickers. In fact, here's the same question that seems to be answered already: [Angular UI Month picker](http://stackoverflow.com/questions/23737270/angular-ui-month-picker) – M. Prokhorov Apr 18 '17 at 09:45
  • Possible duplicate of [Angular UI month picker](http://stackoverflow.com/questions/23737270/angular-ui-month-picker) – M. Prokhorov Apr 18 '17 at 09:45

2 Answers2

1

You could manipulate a JavaScript Date object using the Date Setters but it requires some logic, espacially when adding a month changes the Year. You should consider using momentJS in your project. Moment provides some simple functions to manipulate dates. There is a wrapper to use moment in angular. I can't tell you how to integrate moment in your application unless you provide some sample code.

4n6r
  • 11
  • 3
0

This is what i have tried for the foresaid question.Please help

In Controller.

    $scope.prevMonth = function(){
  date.setMonth(date.getMonth() - 1);
  return $scope.month = $filter('date')(date, 'MMMM');
}

In HTML

 <div class="col col-2 left_arrow"  ng-click="prevMonth()"
    ng-class="{'pointer_events_none':(enableDatesFrom.isSet && enableDatesFrom.epoch > currentMonthFirstDayEpoch)}">
  <button class="button-clear"
          ng-class="{'color_blue':((enableDatesFrom.isSet && enableDatesFrom.epoch < currentMonthFirstDayEpoch) || (!enableDatesFrom.isSet))}">
          <i class="icon ion-chevron-left"></i></button>
</div>{{date | date:'MMM-yyyy'}}</div>
lifeisbeautiful
  • 817
  • 1
  • 8
  • 18