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

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -