technikhil314 / angular-components

Collection of all my open source angular components
https://github.com/technikhil314/angular-components
MIT License
24 stars 30 forks source link

How can I pass in start/end dates via the inline properties? #42

Closed toddhd closed 3 years ago

toddhd commented 5 years ago

I need to use this component within an *ngFor loop in HTML. The objects in the loop have the existing date ranges that I need to populate the control with. So for example, I want to do this:

<div class="form-group" *ngFor="let dateof dates">
    <div class="input-group" 
        daterangepicker 
        [options]="{startDate: date.start, endDate: date.end}" 
        (selected)="selectedDate($event, date)" > 
    </div>
</div>

This is not working for me however. Maybe I'm writing it incorrectly? I know that the control has a setStartDate()/setEndDate() function however I'm not sure how to make those work within the loop.

Any thoughts on how I might get this working?

Thanks!

technikhil314 commented 5 years ago

@toddhd Sorry for late reply. You can process data in array before your component is rendered in ngOninit and pass whole date object as option to daterangepicker component. Correct me if I am not answering it correctly.

fatehuddin commented 5 years ago

How can we set range dynamically? For example: I want to set the startDate to endDate on the basis of backend response. When I override daterangepickerOptions.startDate = '2019/06/01' it does not update the input field.

technikhil314 commented 5 years ago

Can you share any example of what you are trying to do @fatehuddin ??? Since the object gets passed by reference you will have to pass in whole new daterangepickerOptions object

technikhil314 commented 3 years ago

Closing due to inactivity