Làm cách nào để thực hiện câu lệnh có điều kiện trong mẫu html trong GAE GO? Tôi đã cố gắng để thực hiện điều này để làm cho một tùy chọn được chọn trong một chọn thẻ html:Tuyên bố điều kiện trong gói mẫu GAE Go
<select name=".Grade">
<option value=""></option>
<option value="1" {{ if .Grade="1" }} selected="selected" {{ end }}>Grade One</option>
<option value="2" {{ if .Grade="2" }} selected="selected" {{ end }}>Grade Two</option>
<option value="3" {{ if .Grade="3" }} selected="selected" {{ end }}>Grade Three</option>
<option value="4" {{ if .Grade="4" }} selected="selected" {{ end }}>Grade Four</option>
<option value="5" {{ if .Grade="5" }} selected="selected" {{ end }}>Grade Five</option>
<option value="6" {{ if .Grade="6" }} selected="selected" {{ end }}>Grade Six</option>
</select>
Có
{{ if .Grade }} selected="selected" {{ end }}
trong doc tham khảo nhưng điều này chỉ trả về true nếu .Grade
có giá trị. Bất cứ sự giúp đỡ nào cũng được đánh giá cao. Cảm ơn!
Chuyển tới bản phát hành 1.2 – ithkuil