Can't bind attributes on template using directive
I can't seem to bind attributes on the templates using directives. Any help or suggestion would be great!
It is giving me this error:
[$parse:syntax] Syntax Error: Token '{' invalid key at column 2 of the expression [{{$ctrl.CalendarOpen}}] starting at [{$ctrl.CalendarOpen}}].
Here is my directive:
app.directive('datePickerDirective', [function () {
return {
restrict: 'AE',
scope: {
},
template: `
<input type="text" class="form-control"
uib-datepicker-popup="shortDate"
name="date" is-open="{{$ctrl.CalendarOpen}}"
ng-model="test" datepicker-options="dateOptions"
ng-required="true" close-text="Close" />`,
controller: function() {
var $ctrl = this;
$ctrl.CalendarOpen = true
},
controllerAs: '$ctrl',
}
}]);
Remove the double curly
{{brackets from theis-openattribute:The
uib-datepicker-popupdirective is attempting to evaluate theis-openattribute using the $parse Service and Angular Expressions that start with{{are illegal.From the Docs:
In that case there is no error because there is no directive parsing the
idattribute. The expression inside the double curley{{bracket is being evaluated by the $interpolate Service, converted to text, and inserted into the DOM.When a directives parses an attribute as Angular Expression, it is not wise to mix interpolation into that expression.
From the Docs: