2

I'm using the datepicker directive in Angular Bootstrap like so:

<datepicker ng-model="period_start" show-weeks="false" class="bs-dateselector"></datepicker>

How can I detect when a user has actually selected a date?

1
  • ng-change don't do the trick ? Commented Aug 11, 2015 at 8:02

1 Answer 1

3

Exactly as you would detect that a user has typed into an <input ng-model="foo"> (with ng-model) - by using ng-change:

<datepicker ng-model="period_start" show-weeks="false" class="bs-dateselector"
            ng-change="dateChanged()"></datepicker>

That's the idea behind the ngModel directive - that other directives that require: "ngModel", like ng-change or various validators do not need to make any assumptions about the underlying DOM of the input control.

Sign up to request clarification or add additional context in comments.

1 Comment

Of course. I got confused by there not being an attribute to specify an event for when the user selected a date. And so I thought along the lines of watching a scope object or anything like that but that seemed a bit too complicated for what I was trying to achieve. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.