简体   繁体   中英

Ng-disabled not working with AngularStrap's version of the Bootstrap date and time picker

I'm using the AngularStrap version of the Bootstrap datepicker and timepicker in my AngularJS app. I'm trying to make the date picked in the datepicker to a required field and have the following code:

<form name="timepickerForm" role="form" novalidate>
   <input type="text" ng-model="timeDateInput" bs-datepicker required>
   <input type="text" ng-model="timeDateInput" bs-timepicker required>
   <input type="text" ng-model="title">

   <button type="button" ng-click="handleStart()" ng-disabled="timepickerForm.$invalid">Start</button>

</form>

The button does not get disabled even though it has no input. If I put required on the last and regular input, the button gets disabled, so there's nothing wrong with the form or button. I can't find any documentation on the AngularStrap page or in their code to see if it is possible or not.

Does anyone know why it's not working?

The problem was that I, in my controller, set $scope.timeDateInput to an empty string at initialization and that disabled the "required" validation. Once I removed that (or set it to undefined instead) it started working.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM