I tried this:
{{experience.current_work?"Present":{{experience.date_end | date:'MMM yyyy'}}}}
But this is wrong in ternary condition.How do I solve it?
You're already within an expression (ie {{...}}) so you don't need to start a new one
{{experience.current_work ? "Present" : experience.date_end | date:'MMM yyyy'}}
or maybe this if you're worried about order of evaluation
{{experience.current_work ? "Present" : (experience.date_end | date:'MMM yyyy')}}
date_end only like for present also if it's current work ?You can do it like few ways:
Call the function below when you need to check the condition:
$scope.CheckCurrentWork = function() {
if ($scope.experience.current_work) {
//Do as you want "Present"
} else {
//Do as you want
experience.date_end | date: 'MMM yyyy'
}
}
OR
{{experience.current_work ? "Present" : experience.date_end | date:'MMM yyyy'}}
OR
If you want to apply your condition in any directive
<div ng-click="experience.current_work ?'Present' : experience.date_end | date:'MMM yyyy'">