It seems to be a simple question but after a few month working with angular I'm still looking for a clean way to do it.
My template myTimePicker.html is defined in a directive so I got
<myTimePicker></myTimePicker>
Inside my template I have a "pickedTime" object
I need to pickup 3 different times and I dont' want to write 3 templates for the same code (obviously..). I would like to have it defined like a variable for a function, something like:
<myTimePicker ng-***="pickedTime1 as pickedTime" ></myTimePicker>
<myTimePicker ng-***="pickedTime2 as pickedTime" ></myTimePicker>
<myTimePicker ng-***="pickedTime3 as pickedTime" ></myTimePicker>
This works perfectly in ng-repeat when you write
ng-repeat="item in items"
You can use the same template for different items but each item has different variable values inside.
ng-init is not the solution because in this case:
<myTimePicker ng-init="pickedTime = pickedTime1"></myTimePicker>
<myTimePicker ng-init="pickedTime = pickedTime2"></myTimePicker>
...
pickedTime = pickedTime1 = pickedTime2 and they got all the same value pickedTime2
I hope it's clear, thank you for helping!