我正在使用datepipe道来格式化我的date,但我只是不能得到确切的格式,我想要没有解决方法。 我是错误地理解pipe道还是不可能? //our root app component import {Component} from 'angular2/core' @Component({ selector: 'my-app', providers: [], template: ` <div> <h2>Hello {{name}}</h2> <h3>{{date | date: 'ddMMyyyy'}}, should be {{date | date: 'dd'}}/{{date | date:'MM'}}/{{date | date: 'yyyy'}}</h3> </div> `, directives: [] }) export class App { constructor() { this.name = 'Angular2' this.date = new Date(); } } […]
我无法将这个代码从angualr1翻译成angular2,有什么帮助? ng-repeat="todo in todos | orderBy: 'completed'" 这就是我在Thierry Templier的回答之后所做的: html模板: *ngFor="#todo of todos | sort" 组件文件: @Component({ selector: 'my-app', templateUrl: "./app/todo-list.component.html", providers: [TodoService], pipes: [ TodosSortPipe ] }) pipe道文件: import { Pipe } from "angular2/core"; import {Todo} from './todo'; @Pipe({ name: "sort" }) export class TodosSortPipe { transform(array: Array<Todo>, args: string): Array<Todo> { array.sort((a: any, […]