ng- , , $scope .
JavaScript , .
, $scope.deadline , .
, , .
, ,
if ($scope.deadline) {
// do something
} else {
// do something else
}
.
If you want to activate your logic at the moment the input field changes, you can use the $ watch directive in the controller, as Konpat Ta Preechakul suggested , or you can add the ng-change or ng-blur attribute to your input and call the function from the controller:
<input pickadate ng-model="deadline" format="dd/mm/yyyy" placeholder="Select deadline" ng-change="selectedDate()"/>
and
$scope.selectedDate = function(){
if ($scope.deadline) {
} else {
}
}
If you want conditional logic arose as a direct representation tied to the value of real-time values in the input field, then ng-if, ng-showand ng-hidemay be helpful:
<span ng-show="deadline">Show this if deadline has a value</span>
<span ng-hide="deadline">Don't show this if deadline has a value</span>
<span ng-if="!deadline">Don't render this into the DOM at all if deadline doesn't have a value</span>
source
share