Ad
Angular Display Conditional Text In Html Including Conditional Data
I know in Angular2+ we can create condition in html like this:
<p>{{ dynamicData.value? dynamicData.value : dynamicData.default}}</p>
Also we can do something like this:
<p>{{ dynamicData.value? 'text 1' : 'text 2'}}</p>
But I would like to combine this two solutions and I have no idea how to do this. In general I would like to do something like this:
<p>{{ dynamicData.value? 'Dynamic data value is equal: {{dynamicData.value}}' : 'no dynamic data'</p>
Have you any idea how to handle this text interpolation?
Ad
Answer
You do not need to use interpolation within interpolation, you already have access to variables and can try something as below:
<p>{{ dynamicData?.value ? ('Dynamic data value is equal: ' + dynamicData?.value) : 'no dynamic data'}}</p>
Ad
source: stackoverflow.com
Related Questions
- → October CMS create a multi select Form field
- → How to update data attribute on Ajax complete
- → laravel blade templating error
- → should I choose reactjs+f7 or f7+vue.js?
- → How to dynamically add class to parent div of focused input field?
- → Setting the maxlength of text in an element that is displayed
- → Undefined Result for Variable with Javascript innerHTML function
- → Expanding search bar not expanding before search
- → Get the calling element with vue.js
- → Blade: how to include a section in one page but not in another
- → How to print/log reactjs rendered dom?
- → how to write react component to construct HTML DOM
- → How to add a timer in HTML5 and Javascript?
Ad