請問用 Angular 7 如何進行 login server

在下最近在學 Angular CLI。使用的 Angular 是 7.0版
以下是在下的Server 規劃:
http://localhost:4200/ 是 Angular 網站
http://localhost:8080/ 是 backend api (含login),已開啟 CORS

現在要實做在 Angular 的網站上登入 backend 的功能。
就我的理解,就是 Angular 要實做 form submit 並且取回 backedn 回傳的 session id (or cookie)
請問哪裡有這樣的範例?
謝謝幫忙

後端是用什麼開發的?

你好,
我後端是用 Java /tomcat 開發的。

可以使用 cookie 或是 JWT 的方式,朝這方向去看,應可以看到相關的文件

謝謝喔。
我已經試驗出來了。在使用 http的時候,在 httpOptions 中加入
withCredentials: true 就可以了

login(aUserId: string, aPasswd: string): Observable<any> {
console.log('aUserId=' + aUserId);
return this.http.post(
  'http://localhost:8080/auth-api/login',
  {userId: aUserId, passwd: aPasswd},
  {
    withCredentials: true
  });

}

1個讚