angularjs - How i can access the scope vars mentioned in attributes -
for datepicker control added custom attributes input element:
<input id="inputdatepicker" ng-model="currentappointment.date" data-date-format="dd.mm.yyyy" datepicker changedates="currentappointment.start"> for created directive build datepicker:
.directive('datepicker', function ($filter) { return { restrict: 'a', require: '?ngmodel', link: function ($scope, $element, $attributes, $ctrl) { $scope[$attributes.changedates] ... not work $element.datepicker(); } } }); how can access scope vars mentioned in changedates-attribute? in example above want access $scope.currentappointment.start
you can use $parse service:
var model = $parse($attributes.changedates) to value
model($scope) to set value
model.assign($scope, value)
Comments
Post a Comment