Friday, 15 August 2014

Set min date to current date in angularJS input -


AngularJS, we can min attribute input type = "on how to set Are "from the current date (of today)?

  & lt; Input type = "date" ng-model = "data. Start date" name = "start date" min = ?? / & Gt;  

Edit1

The suggestion I gave below was added to the controller -

  $ Scope .currentDate = new date ();  

and in HTML -

  & lt; Input type = "date" ng-model = "data.startdate" name = "start date" required minimum = "{{CurrentDate | Date: 'yyyy-MM-dd'}}" /> & Lt; Span ng-show = "form. Start date. $ Dirty & form. Startdet $ invalid" & gt; & Lt; Span ng-show = "form.startout. $ Error.required" & gt; Start date is required & lt; / Span & gt; & Lt; Span ng-show = "form.start.date. $ Error.min" & gt; The start date should not be less than the current date & lt; / Span & gt; & Lt; / Span & gt;  

Now, not allowing to select less than 2015 only. In addition, if the entire date is less than the current date, then no validation is being done. >

Thanks

Yes you can set a minimum value accordingly:

  & lt; [Ng-required = ""] [ng-change = "" [ng-change = "" [ng-change = "[required =" "] [required] "] & Gt;         String  - If the value is less than the minimum entered then the minimum verification error key sets it should be a valid ISO date string (yyyy-MM-dd).   

Edit field to set the current date:

Controller:

  function Ctrl ($ Scope) {$ scope.date = new date (); }  

See:

  & lt; Input type = "date" NG-model start = "Detakstartdet" Name = "" hours = "{{date: Date: 'yyyy-MM-dd'}}" />  
< P> Work example


No comments:

Post a Comment