angular-pipe

How to change time from 24 to 12 hour format in angular 5

大憨熊 提交于 2020-07-08 13:34:28
问题 I have used input type time in my application to receive time: <mat-input-container> <input matInput formControlName="start_time" type="time" placeholder="Time Start"> <p class="invalid-text" *ngIf="dvrForm.controls.start_time.invalid && (dvrForm.controls.start_time.dirty || dvrForm.controls.start_time.touched)"> <span *ngIf="dvrForm.controls.start_time.errors.required"> Start Time is required.</span></p> And after i store data through input it gets stored in 24 hour format : So now when I

How to concat a string after using slice pipe

点点圈 提交于 2020-04-30 06:08:05
问题 I'm new to Angular. I want to cut short strings that are longer than 15 characters (say) and then add ... at the end. For eg: Name: Tanzeel, Role: Intern Address: Bangal..., Likes: C, CPP, ..., I'm using p-chips from PrimeNg to display some tags. I'm not getting any error. Actually I'm not getting anything, my web page is just blank. Even the console log is also clean. Here's my code: <p-chips [(ngModel)]="tokens"> <ng-template let-item pTemplate="item"> {{item | slice:0:15+'...'}} </ng

angular pipe to filter text with multi level key

≯℡__Kan透↙ 提交于 2020-01-25 08:40:08
问题 I have an angular pipe which just filter outs the text from ngFor. It works very well with single level of json object but fails when there is multi level object. Pipe: import { Pipe, PipeTransform } from '@angular/core'; @Pipe({ name: 'simpleSearch' }) export class SimpleSearchPipe implements PipeTransform { public transform(value, keys: string, term: string) { if (!term) return value; return (value || []) .filter(item => keys.split(',').some(key => { item.hasOwnProperty(key) && new RegExp

Translations based on specific keys in custom JSON files and business cases with ngx-translate (Angular 7)

被刻印的时光 ゝ 提交于 2020-01-06 07:14:18
问题 I have a working implementation of the ngx-translate library for Angular, based on several .json files (for example, stored in assets/i18n/en.json ). I want to achieve the following: There is always a default JSON (for example de.json ) and additionally always specific JSON files (for example de_specific.json ) that only contain specific translations using the same keys as the respective default JSON. If there is e.g. a translation in the default de.json with "Home": "Startseite" , then the

Pass multiple values to pipe in Angular 6

那年仲夏 提交于 2020-01-02 01:31:05
问题 I need to create a search form in Angular 6 with pipe and must pass multiple arguments to pipe . nameSearch , emailSearch , roleSeach , accountSearch <tr *ngFor="let user of data | searchuser: nameSearch" ></tr> and this my pipe : @Pipe({ name: 'searchuser' }) export class SearchuserPipe implements PipeTransform { transform(users: IUser[], nameSearch: string): IUser[] { if(!users) return []; if(!nameSearch) return users; nameSearch=nameSearch.toLocaleLowerCase(); return users.filter(item=> {

Angular 4 - How to use currency pipe in input type

♀尐吖头ヾ 提交于 2020-01-01 04:59:40
问题 I have an HTML input: <input [(ngModel)]="item.value" name="inputField" type="text" /> I want to format its value and use an existing pipe: .... [(ngModel)]="item.value | currency:'USD':true" ..... Also I'm trying to use it the following way, but it's giving me desirable output for the first time and showing error while updating the field: <input type="text" [ngModel]="item.value | currency:'USD':true" (ngModelChange)="item.value=($event)"> The above code leads to following error. ERROR Error

Use async pipe in ngFor on Observable of Observables (Angular)

北慕城南 提交于 2019-12-30 08:40:52
问题 I have variable defined like this: myVar: Observable<Observable<MyObject>[]> . I am using Angular4 feature to enumerate with async pipe *ngFor="let obsMyObject of (myVar | async)" now I have Observable of MyObject, but I need just MyObject. I could write something like that: <div *ngFor="let obsMyObject of (myVar | async)"> <div *ngIf="let obsMyObject | async; let MyObject"></div> </div> but I can not do this in inner div, because I am setting flex order (which doesn't have any effect on

AsyncPipe initial value null only if subscription is not shared

若如初见. 提交于 2019-12-24 18:34:58
问题 Given a template that looks like something like this <some-component *ngIf="someColdObservable$ | async" [result]="someColdObservable$ | async" ></some-component> and an observable that looks like this: someColdObservable$: this.store.pipe( select(isAllowedToDoThis), filter(Boolean), flatMap(() => apiRequest()) ); The someColdObservable$ gets subscribed to twice (as expected), which in turn issues two api calls (this is obviously a code smell, but let's disregard that at the moment). In this

Ngx-charts can't load bar charts directly with async pipe in angular

我的未来我决定 提交于 2019-12-23 03:10:04
问题 My problem is similar to this stackoverflow post When I use async pipe to observe data from firebase and show it in chart, I can see the chart but prompt null error in console. Without async pipe, all errors are gone but I can't fetch data (duh it's async data). Help me please. 回答1: Cause This is happening because the component cannot work with null values for results . Why? Async pipe is, as you say, used when you do not want to (or do not need to) subscribe in the component code, but do it