angular-pipe

Format date as dd/MM/yyyy using pipes

痞子三分冷 提交于 2019-11-26 14:10:18
I'm using the date pipe to format my date, but I just can't get the exact format I want without a workaround. Am I understanding pipes wrongly or is just not possible? //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(); } } plnkr view Pipe date format bug fixed in Angular

OrderBy pipe issue

你离开我真会死。 提交于 2019-11-26 13:03:36
I'm not able to translate this code from Angualr 1 to Angular 2: ng-repeat="todo in todos | orderBy: 'completed'" This is what i've done following the Thierry Templier's answer: Component template: *ngFor="#todo of todos | sort" Component code: @Component({ selector: 'my-app', templateUrl: "./app/todo-list.component.html", providers: [TodoService], pipes: [ TodosSortPipe ] }) Pipe code: 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, b: any) =>

Angular 4 Filter Search Custom Pipe

╄→尐↘猪︶ㄣ 提交于 2019-11-26 11:27:56
问题 So I am trying to build a custom pipe to do a search filter of multiple values in a ngFor loop. I have looked for a number of hours for a good working example, and most of them are based on previous builds and don\'t seem to work. So I was building the Pipe and using the console to give me the values. However, I cannot seem to get the input text to show up. Here are the previous places I have looked to find working examples: Angular 4 Pipe Filter http://jilles.me/ng-filter-in-angular2-pipes/

OrderBy pipe issue

和自甴很熟 提交于 2019-11-26 03:36:54
问题 I\'m not able to translate this code from Angualr 1 to Angular 2: ng-repeat=\"todo in todos | orderBy: \'completed\'\" This is what i\'ve done following the Thierry Templier\'s answer: Component template: *ngFor=\"#todo of todos | sort\" Component code: @Component({ selector: \'my-app\', templateUrl: \"./app/todo-list.component.html\", providers: [TodoService], pipes: [ TodosSortPipe ] }) Pipe code: import { Pipe } from \"angular2/core\"; import {Todo} from \'./todo\'; @Pipe({ name: \"sort\"

Format date as dd/MM/yyyy using pipes

好久不见. 提交于 2019-11-26 03:06:04
问题 I\'m using the date pipe to format my date, but I just can\'t get the exact format I want without a workaround. Am I understanding pipes wrongly or is just not possible? //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

NgFor doesn&#39;t update data with Pipe in Angular2

爱⌒轻易说出口 提交于 2019-11-26 01:37:37
问题 In this scenario, I\'m displaying a list of students (array) to the view with ngFor : <li *ngFor=\"#student of students\">{{student.name}}</li> It\'s wonderful that it updates whenever I add other student to the list. However, when I give it a pipe to filter by the student name, <li *ngFor=\"#student of students | sortByName:queryElem.value \">{{student.name}}</li> It does not update the list until I type something in the filtering student name field. Here\'s a link to plnkr. Hello_world.html