iT邦幫忙

1

Angular Module共用Service資料

簡單說明一下
下圖為專案的架構

目前遇到一個狀況是我在登入時想要塞一些資料進去 A Service ,方便我在其他Module(如架構圖)可以拿來使用,但目前測試過很多方式都宣告失敗/images/emoticon/emoticon02.gif

我爬過google大多數人都推薦寫一個共用的Module去繼承 A Service,但我還是抓不到資料,再麻煩高手幫幫忙

參考資料
https://angular-2-training-book.rangle.io/modules/shared-modules-di

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

2 個回答

1
dragonH
iT邦超人 5 級 ‧ 2019-08-06 19:57:31
最佳解答

先說我沒碰過 Angular /images/emoticon/emoticon07.gif

我只是看到標題

好奇 Angular 沒有像 vue 一樣

有類似 vuex 的 lib 嗎

所以就去找

就找到 NGXS

看起來的確跟 vuex 很像

如果不排斥第三方 lib

或許可以試試

1
thomas550728
iT邦新手 5 級 ‧ 2019-08-08 17:09:13

怎麼會呢"
A Service 宣告在app.modeule 及使用 providers: [AService]
不就是全域的了,還是我誤解你的需求

hugo8319 iT邦新手 4 級 ‧ 2019-08-08 17:26:36 檢舉

後來測試出來是因為我導頁的地方是使用 [href] ,所以每次導過去都會重新整理 /images/emoticon/emoticon03.gif
應該要使用 [routerLink]才對

我要發表回答

立即登入回答