4

When the timepicker control is inside a form and has an initial 'valid' default value, it should validate and $scope.formname.$valid should be true. However, what I am seeing is that unless the user interacts with the control, it's not validated and the form is not in valid state, this is not acceptable since the user may not even want to change the default time value. Any ideas what can be done for angular to validate the control with its default value and form respectively.

https://plnkr.co/edit/p1I2NoNpg3XMzijHUadi?p=preview

<form name="myForm" novalidate>
  <uib-timepicker ng-model="time" template-url="timepicker.html" hour-step="1" ng-required="true" minute-step="1" show-meridian="false" ></uib-timepicker>

  <input type="submit" value="Form state" ng-click="alertState()"></button>
</form>




 var app =  angular.module('demo',['ui.bootstrap']);


  app.controller('myCtrl',[ '$scope', function($scope) {



  $scope.alertState = function() {
    alert($scope.myForm.$valid);
  };

  }]); 
LaserBeak
  • 3,257
  • 10
  • 43
  • 73
  • Making it dirty may help: [http://stackoverflow.com/questions/18071648/angular-js-programmatically-setting-a-form-field-to-dirty](http://stackoverflow.com/questions/18071648/angular-js-programmatically-setting-a-form-field-to-dirty) – DylanH Jan 01 '16 at 00:23
  • 1
    did you ever figure this out? – darewreck Jun 04 '16 at 01:59

0 Answers0