How to get new changed value from <sp-date-picker> directive?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-12-2018 05:32 AM
How to get new changed value from <sp-date-picker> directive?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-12-2018 07:37 AM
this is how I have set it up and it works fine:
HTML:
<sp-date-picker field="c.delivery" ng-model="delivery.value" ng-model-options="{getterSetter: true}" sn-disabled="false"></sp-date-picker>
Client Controller:
c.delivery = {
displayValue: '',
value: '',
name: 'delivery'
};
$scope.$watch('c.delivery.value', function(oldVal, newVal) {
c.deliveryDate = newVal;
});
But honestly, you should be able to access the value in c.delivery.value as well.
The watch listener will track when it changes though if you need to do something with it like validation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-13-2018 11:37 PM
Hi Jon,
Many thanks for your quick response, I tried watch option but it breaks field as shown below.
HTML:
<div>
<sp-date-picker field="delivery" ng-model="delivery.value" ng-model-options="{getterSetter: true}" sn-disabled="false"></sp-date-picker>
<!-- your widget template -->
</div>
Client Controller:
function() {
/* widget controller */
var c = this;
c.delivery = {
displayValue: '',
value: '',
name: 'delivery'
};
console.log(c.delivery.value+"feroz");
$scope.$watch('c.delivery.value', function(oldVal, newVal) {
c.deliveryDate = newVal;
});
}
Preview:
Regards,
Feroz

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-19-2019 07:39 AM