LINK TO see visualisation oа my question LINK
I'm totally lost. Have read lots of SO replies (closest problem was here)
html:
<div title="Employment start date"
ng-model="tabsData.employment_start_date"
input-date="{{dateFormats.getCurFormat()}}"></div>
I need to show & edit (by custom directive) Date value;
How to bind (bidirectionally) my OUTER ng-model (tabsData.employment_start_date) with INNER ng-model (???) on <datepicker> ?
(see below <---------- HERE !!! sign tagretting to the <datepicker>'s ng-model attr in the snippet where I need to past Bidirectionally binding)
having some kind of directive:
directive('inputDate', function factory(dateFilter) {
return {
require:'^ngModel',
restrict:'A',
replace: true,
template:'<div class="control-group">
<div class="controls">
<label>{{title}}</label>
<input class="dateInputValue"
ng-model="formattedDate"
readonly
ng-click="showPicker=!showPicker"/>
<div class="datePickerBlock">
<button class="datePickerBtn"
ng-click="showPicker=!showPicker">
<i class="whhg icon-calendar"></i>
</button>
<datepicker
class="datePicker"
show-hide="{{showPicker}}"
ng-model=" ??? " <--------------------- HERE !!!!
show-weeks="true"
starting-day="1"
date-disabled="disabled(date, mode)">
</datepicker>
</div>
</div>
</div>',
link:function (scope, elm, attrs, ngModelCtrl) {
ngModelCtrl.$formatters.unshift(function (modelValue) {
scope.formattedDate = dateFilter(modelValue, attrs.inputDate || 'medium');
return scope.formattedDate;
});
ngModelCtrl.$parsers.unshift(function(viewValue) {
var date = new Date(viewValue);
return isNaN(date) ? '' : date;
});
}
};
});
In addition my 2nd question, why when I replace template to templateUrl property:templateUrl: '/cached/ui-elements/inputBool.html' referencing to:
/* Template */
angular.module("/cached/ui-elements/inputDate.html", []).run(["$templateCache", function($templateCache) {
$templateCache.put("/cached/ui-elements/inputDate.html",
"<div class=\"controls\">\n"+
"<input class=\"dateInputValue\" " +
"ng-model=\"ngModelLocal\" " +
"readonly " +
"ng-click=\"showPicker=!showPicker\"/>\n"+
<MY-DATEPICKER ng-model="ngModelLocal"></MY-DATEPICKER>
"</div>"
}]);
attrs.dateFormat equals to {{dateFormats.getCurFormat()}} STRING! (without returning an actual expression execution result on the $scope as before with template property)
Guys help ;)