0

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?

2 Answers 2

2

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')}}
Sign up to request clarification or add additional context in comments.

2 Comments

won't this try to filter whole instead of date_end only like for present also if it's current work ?
@AnikIslamAbhi nope, at least not in the quick test I just did. I suppose you could wrap the false branch in parentheses just to be sure
-1

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'">

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.