angular2專案教程 微型Blog系統2

2021-07-28 14:23:22 字數 936 閱讀 2798

route,module,component

靜態路由

這樣配置,依賴的元件全打包,會很大。

非同步路由,就不會

loadchildren

——————————

架構思想

元件化,依賴注入,資料繫結

————————————————

雙大括號和[(ngmodel)]值繫結,()事件繫結

——————————————————————

元件間通訊

共享元件

給子元件傳引數。

@component()

export class userinfocomponent implements oninit

根據不同的場景,傳遞進來

直接把paneltitle作為自定義標籤的乙個屬性

——————————————————————————————

給父元件傳值:

子元件定義乙個

@output()

public follow = new eventemitter();

dofollow()

——————————————————————————

services進行通訊,同步登入狀態,利用userloginservice

不僅被注入到『使用者登入』元件,還被注入到post-detail-main.component.ts,userloginservice是同乙個例項

訂閱同乙個

ngoninit()

————————————————————————————————

生命週期鉤子

ngoninit //元件初始化完成之後,paneltitle才會有值

export class booleanpipe implements pipetransform {

實現乙個pipetransform 介面

angular2專案教程 微型Blog系統1

照應的ppt 1.ng build prod aot angular cli會在專案根目錄下生成乙個dist目錄,裡面就是編譯 壓縮好的檔案了。2.ng serve 啟動服務,修改了檔案,瀏覽器改變 3.ng serve prod aot 就會 變小 建立乙個元件 ng g c user user....

angular2專案教程 微型Blog系統3

js太多,就會http請求很多 js少,單個檔案又太大 這需要設計者權衡 模組和共享模組 共享模組 sharedmodule和postsharedmodule 匯入到manage和user模組 模組懶載入 loadchildren點到路徑的時候才載入這個模組,非同步載入 第三種元件傳遞引數,路由 m...

angular2專案關於動畫的處理

animations動畫在angular2官網裡面已經講解很詳細了,那麼動畫功能在實際專案中應該如何組織檔案,動畫檔案放在哪個位置,如何來組織結構使得動畫模組和其他模組之間運作調理清晰呢,下面參照nicefish來講解一下 一 定義動畫 拿乙個例子來簡單分析一下 import from angula...