I’m making my own widget for entering IP addresses, since there aren’t any in standard ones and offered by other developers. Almost everything worked out, I can enter the address, it is written to the specified channel and transmitted to me via mqtt.
But there is a problem: when refreshing the page, if you do not enter a value in the text field, then an empty value is written to the channel. This is due to the fact that the value of the variable “ip_addr_value” is not set after the page refresh (as I understand it …). I bring the widget code, can any of the specialists help me? I will be very grateful!!!
<style>
.ip-addr-input-table {
width: 100%;
}
.ip-addr-table-cell {
padding: 5px;
height: 100%;
display:block;
}
.ip-addr-btn {
border: 1px solid #2E6DA4;
border-radius: 4px;
background-color: #4E7EA7;
background-image: none;
color: #FFFFFF;
font-weight: normal;
margin: 0;
width: 100%;
}
.ip-addr-text {
border: 1px solid #2E6DA4;
border-radius: 4px;
background-color: #D7E2EC;
background-image: none;
font-weight: normal;
margin: 0;
width: 100%;
}
</style>
<div>
{{ngModel.name}}
</div>
<table class="ip-addr-input-table">
<tr>
<td class="ip-addr-table-cell">
<input type="text" class="value ip-addr-text" ng-model="ip_addr_value" ng-value="itemValue(config.item)"> </input>
</td>
<td class="ip-addr-table-cell">
<button type="button" class="btn btn-default btn-lg ip-addr-btn" ng-click="sendCmd(config.item, ip_addr_value)">
{{config.buttonText}}
</button>
</td>
</tr>
</table>