angular 管道
生活随笔
收集整理的這篇文章主要介紹了
angular 管道
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
管道將數(shù)據(jù)作為輸入并將其轉(zhuǎn)換為所需的輸出(實現(xiàn)對數(shù)據(jù)的格式化)。
管道可以接受任意數(shù)量的可選參數(shù)來微調(diào)起輸出,要向管道添加參數(shù),請使用冒號(:)跟隨管道名稱,然后使用參數(shù)值,如:date: "MM/dd/yy",如果管道接受多個參數(shù),請用冒號分割值如:slice:1:5。
<p>The hero's birthday is {{ birthday | date:"MM/dd/yy"}}</p>birthday = new Date(1988, 3, 15);復(fù)制代碼<p>The hero's birthday is {{ birthday | date:format }}</p><button (click)="toggleFormat()">Toggle Format</button> toggle = true; // start with true == shortDate get format() { return this.toggle ? 'shortDate' : 'fullDate'; } toggleFormat() { this.toggle = !this.toggle; }復(fù)制代碼<p>The chained hero's birthday is{{ birthday | date:'fullDate' | uppercase}}</p>復(fù)制代碼轉(zhuǎn)載于:https://juejin.im/post/5c86092df265da2dde072489
總結(jié)
以上是生活随笔為你收集整理的angular 管道的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 单点登录系统SSO概述 | 单点登录讲解
- 下一篇: Flutter开发环境安装