Home  >  Q&A  >  body text

angular.js - angular datepicker 怎么设置出现时显示某个月的时间

怎么设置datepicker一出现就显示某个月的日期,比如2012年2月 2018年4月 等。

大家讲道理大家讲道理2713 days ago694

reply all(3)I'll reply

  • PHP中文网

    PHP中文网2017-05-15 17:03:26

    Just give a default value in ng-model

    reply
    0
  • 怪我咯

    怪我咯2017-05-15 17:03:26

    Look at whether your component accepts a formatted string or a DATE string, and then assign a value to ng-model.
    Because different date components may receive different values, to avoid the possibility that if you fill in a value, the component cannot recognize it, and then there will be a bug when the date component pops up.

    reply
    0
  • 某草草

    某草草2017-05-15 17:03:26

    Assign default time

    function Format(date,type) 
          { 
            var new_date;
            var year  = date.getFullYear();
            var month = date.getMonth()+1;
            var day   = date.getDate();
    
            if (day>0 && day<10) {
              day = '0'+day;
            }
    
            if (month>0 && month<10) {
              month = '0'+month;
            }
    
            switch(type) {
              case 1:
                new_date  = year+'-'+month+'-'+day;
                break;
              case 2:
                new_date  = year+'-'+month+'-'+(day-6);
                break;
            }
            
            return new_date; 
          }

    reply
    0
  • Cancelreply