This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Sometimes we do cool stuff like this... | |
let tacoType = hasQueso ? 'supreme' : 'normal' | |
// Or this in our markup... | |
`ng-class="isActive && 'md-primary'"` | |
// Or this to set default values... | |
this.color = config.color || 'blue' | |
// Sometimes though we'd like to have more | |
// options at our disposal when conditionally | |
// assigning to a variable. | |
// Enter the nested ternary. With some proper formatting, | |
// it actually reads quite nicely. | |
let dogSize = breed === 'rottweiler' ? 'big' : | |
breed === 'boxer' ? 'medium' : | |
breed === 'pug' ? 'small' : | |
'medium' // default |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment