预选年份格式的Angular JS日期选择器中的年份

时间:2016-06-05 13:11:25

标签: javascript html angularjs

我有一个日期选择器,并将模式设置为年份以选择一年。我有2016年,1994年等年份的价值观。 如果我在该日期选择器输入的ng-model中设置这些值,会抛出错误&显示错误的一年。

另外,当选择年份

时,我只想要年份值

JS代码:

 private int notificationId = new Random().nextInt(8000) + 1;
    public static HashMap<Integer, String> NumberHash = new HashMap<Integer, String>();

  @Override
public void successCallback(String channel, Object message) {
                        System.out.println("SUBSCRIBE : " + channel + " : "
                                + message.getClass() + " : " + message.toString());

   int Number = Integer.parseInt(message.toString());
              if(NumberHash.get(Number) == null){
                 NumberHash.put(Number, "requested");
                Log.d("number from Test.java"," " + Number);
                //notify
  Intent notificationIntent = new Intent(getBaseContext(),NotificationActivity.class);

  PendingIntent notificationPendingIntent = PendingIntent.getActivity(
               getApplicationContext(), 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);      

  NotificationCompat.Action action = new NotificationCompat.Action.Builder(
                                    R.id.icon_only, null,
                                    notificationPendingIntent).build();

  NotificationCompat.Builder notificationBuilder =
                                    new NotificationCompat.Builder(getBaseContext())
                                            .setSmallIcon(R.drawable.bell)
                                            .setContentTitle("Number is ")
                                            .setContentText(message.toString())
                                            .setVibrate(new long[]{0, 1000, 1000, 0, 0})
                                            .setLights(Color.BLUE, 3000, 3000)
                                            .setAutoCancel(true)
                                            .addAction(action)
                                            .extend(new NotificationCompat.WearableExtender()
                                                    .setContentAction(0));


                            NotificationManagerCompat notificationManager =
                                    NotificationManagerCompat.from(getBaseContext());

                            notificationManager.notify(notificationId, notificationBuilder.build());
                            Log.d("ID", "id = " + notificationId);
                        }

                    }

HTML:

$scope.open = function() {
      $scope.opened = true;
  };

  $scope.yu = 2200;

  $scope.dateOptionsForYear={
    showWeeks: false,
    datepickerMode : 'year',
    minMode : 'year'  
  }

我已经设置了一个Plunker。这是link

1 个答案:

答案 0 :(得分:1)

将代码设为

$scope.yu = 2200;

$scope.yu = new Date("1994");