How to get new changed value from <sp-date-picker> directive?

shferoz1
Mega Contributor

How to get new changed value from <sp-date-picker> directive?

3 REPLIES 3

Jon Barnes
Kilo Sage

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.


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:


find_real_file.png



Regards,


Feroz


xiaix
Tera Guru

find_real_file.png

 

find_real_file.png