I created a directive to handle date on a page:

<form class="form-horizontal">
    <div class="control-group">
        <label class="control-label" for="inputName">Name</label>
        <div class="controls">
            <input type="text" id="inputName" placeholder="Name" 
ng-model="data.Name" />
        </div>
    </div>
    <div class="control-group">
        <label class="control-label" for="inputHasRange">Range</label>
        <div class="controls">
            *<input type="checkbox" id="inputHasRange" 
ng-model="data.HasRange" />*
        </div>
    </div>
    <div class="control-group">
        <label class="control-label" for="inputRangeStart">Range 
Start</label>
        <div class="controls">
            *<input type="text" class="span2" id="inputRangeStart" 
ng-model="data.RangeStart" ng-disabled="!data.HasRange">*
        </div>
    </div>
    <div class="control-group">
        <label class="control-label" for="inputRangeEnd">Range End</label>
        <div class="controls">
*            <input type="text" class="span2" id="inputRangeEnd" 
ng-model="data.RangeEnd" ng-disabled="!data.HasRange">*
        </div>
    </div>
    <div class="controls">
        <a href="" class="btn btn-primary" ng-click="save()"><i 
class="icon-ok icon-white"></i> Save</a>
    </div>
</form>


Then further on in the code I had a created a script tag containing:

<script>
    $(document).ready(function () {
        var rangeStart = $('#inputRangeStart').datepicker({
            format: 'mm-dd-yyyy'
        }).on('changeDate', function (ev) {

        }).data('datapicker');

        var rangeEnd = $('#inputRangeEnd').datepicker({
            format: 'mm-dd-yyyy',
            onRender: function (date) {
                //return date.valueOf() < rangeStart.date.valueOf() ? 
'disabled' : '';
            }
        }).on('changeDate', function (ev) {

        }).data('datapicker');
    });
</script>

This all works greatly! The problem arrised when I added multiple 
directives on the same page. I can't use a hardcoded javascript variable 
"inputRangeStart", because there will be more then 1 on the same page! How 
should I deal with this? I made sure that the $index of the ng-repeater is 
transfered to the directive, but I can't seem to figure out how to deal 
with this on the javascript side...

Any suggestions would be greatly appreciated!

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to angular+unsubscr...@googlegroups.com.
To post to this group, send email to angular@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to