FAQ
I am having problems calling methods in html/template and I cannot work out
what I am doing wrong.

type EventBo struct {
id int

}

func (this *EventBo) Id() int {

return this.id

}
I then use a struct to pass the EventBo to the template

type ActivityDetailsViewModel struct {
BaseViewModel
Event service.EventBo
}


{{if .Event}}
<tr>
<td>Id</td>
<td>{{.Event.Id}}</td>
</tr>
{{end}}

The error output from the template is: "can't evaluate field Id in type
service.EventBo."

Any ideas as I have been looking at this for hours but cant understand why
it is not rendering the information?

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Robfig at Feb 16, 2013 at 7:53 pm
    Change your Id() method to have a non pointer receiver, or pass a pointer as the template arg

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedFeb 16, '13 at 7:39p
activeFeb 16, '13 at 7:53p
posts2
users2
websitegolang.org

2 users in discussion

Ollie Castle: 1 post Robfig: 1 post

People

Translate

site design / logo © 2022 Grokbase