angularjs - Go + Angular: loading base html -


I'm trying to write an app in the go with thumb. I'm not sure that I have the concept correct, but basically I should serve a simple HTML that loads angular and app (js) and the rest is controlled by AJAX requests. I do not know how the HTML file is served on each non-ajax request on every path? I would like to use the Gorilla Mix but I do not know how to do it.

Is this the right direction?

On every request that does not have any known url, index.html - or whatever your base Send Appellar App file

There is a NotFoundHandler in Gorilla / Max, which is a handler for everyone that does not match any other routes, you can assign your own handlers to:

Solution with Gorilla / MQ:

  func main () {r: = mux.NewRouter () r. HandleFunc ("/ foo", fooHandler) r.NotFoundHandler = http.HandlerFunc (notFound) http.Handle ("/", r)}  

is not, while not:

  func notFound (w http.ResponseWriter, r * http.Request) {http.ServeFile (w, r, "static / index.html")}  

Assuming your base file is in static / index.html :).

Now all your requests that are not of other requests (therefore, in that setup - no Ajax calls defined in routes) will serve the index file Url which can be controlled by ngRoute or ui-router .


Comments

Popular posts from this blog

c# - SignalR: "Protocol error: Unknown transport." when navigating to hub -

class - Kivy: how to instantiate a dynamic classes in python -

java - Algorithm negotiation fail SSH in Jenkins -