Я запускаю свой сервис go, а затем возникает ошибка, которую я не знаю, как ее решить (panic: template: index.html: 20: функция "item" не определена), как предполагается, для моего html но как я могу решить это:
Код HTML (угловой)
<table id="mytable" class="table table-bordred table-striped">
<tr>
<th>ID</th>
<th>Name</th>
<th>Last Name</th>
<th>Second Last Name</th>
</tr>
<tbody>
<tr ng-repeat="item in ListOfUsers">
<td ng-if="ListOfUsers.length!==0">{{item._id}}</td>
<td ng-if="ListOfUsers.length!==0">{{item._name}}</td>
<td ng-if="ListOfUsers.length!==0">{{item._lastName}}</td>
<td><a class="btn btn-primary btn-xs" href="#!EditUser/{{item.Id}}">
<span class="glyphicon glyphicon-pencil"></span></a>
</td>
<td><a class="btn btn-danger btn-xs"ref="#!DeleteUser/{{item.Id}}">
<span class="glyphicon glyphicon-trash"></span></a>
</td>
</tr>
</tbody>
</table>
Сервис Go
func main(){
fs := http.FileServer(http.Dir("Resources"))
go print10000numbers("world")
print10000numbers("hello")
router := mux.NewRouter()
router.HandleFunc("/People",GetPeopleHandler).Methods("GET")
router.HandleFunc("/InsertPeople",InsertPersonHandler).Methods("POST")
router.HandleFunc("/UpdatePeople/{id}",UpdatePersonHandler).Methods("POST")
router.HandleFunc("/DeletePeople/{id}",DeletePersonHandler).Methods("DELETE")
router.Handle("/Resources/Angular/angular.js",http.StripPrefix("/Resources", fs))
router.Handle("/Resources/JS/AppController.js",http.StripPrefix("/Resources", fs))
tpl = template.Must(template.ParseGlob("Views/*"))
fmt.Println("Listening")
router.HandleFunc("/",chargeHtml).Methods("GET")
http.ListenAndServe(":8081",router)
}
func chargeHtml(w http.ResponseWriter,r *http.Request){
tpl.ExecuteTemplate(w,"index.html",nil)
}