I want to change my button's text if a value is true/false. here is my code:
<button
class="btn btn-primary table-button"
type="button"
data-toggle="collapse"
:data-target="`#collapse${row.num}`"
aria-expanded="false"
aria-controls="collapseExample"
@click="expanded = !expanded"
ref="tableButtonText">
{{ tableButtonText }}
</button>
data(){
return{
expanded:"",
tableButtonText:""
}
},
watch: {
expanded() {
if (this.expanded) {
this.tableButtonText = "Hide details";
} else if (!this.expanded) {
this.tableButtonText = "View details";
}
}
},
It does change the value of expanded and tableButtonText but the screen doesn't display the button at all. Seems the issue is that html doesn't render {{ tableButtonText }}. What seems to be the issue and how can I fix it?