Answer the question
In order to leave comments, you need to log in
Can GOlang be used to route Angular2 pages?
Please tell me, for example, I wrote a small web application in Angular2 with several pages, all routes are implemented inside Angular2 like this
import {Component} from 'angular2/core';
import {RouteConfig, ROUTER_DIRECTIVES, ROUTER_PROVIDERS} from 'angular2/router';
import {AuthComponent} from './auth.component';
@Component({
selector: 'my-app',
template: `
<h1></h1>
<router-outlet></router-outlet>
`,
directives: [ROUTER_DIRECTIVES],
providers: [ ROUTER_PROVIDERS]
})
@RouteConfig([
{ path: '/auth', name: 'Auth', component: AuthComponent, useAsDefault: true }
])
export class AppComponent {
}
http.Handle("/", http.FileServer(http.Dir("./app/web/")))
http.ListenAndServe(":8080", nil)
Answer the question
In order to leave comments, you need to log in
You can enable routing on the main page and use:
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, "index.html")
})
http.Handle("/assets/", http.StripPrefix("/assets/", http.FileServer(http.Dir("./path/to/assets"))))
You can do this:
Or this:
Js routing is not connected to the web server in any way.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question