question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

how to use pipes?

See original GitHub issue

Hi, I want to change form of dates. for example:

2016-10-09T07:00:41.387Z to 2016/10/09, in angular 2 we can use ‘shortDate’ pipe parameter, but how do it in ng2-smart table

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

46reactions
AlexTheBestcommented, Oct 22, 2016

Hey mmdsharifi, i ran into this a few weeks ago and the way i solved it is using the valuePrepareFunction property.

For example to format the date:

      valuePrepareFunction: (date) => { 
        var raw = new Date(date);

        var formatted = this.datePipe.transform(raw, 'dd MMM yyyy');
        return formatted; 
      }

Make sure you export the datePipe and define it in the constructor

import { DatePipe } from '@angular/common';

constructor( private datePipe: DatePipe ){ }

6reactions
ohabashcommented, Oct 29, 2018

Oh i see… I got stuck at 2 places.

  1. valuePrepareFunction needs to go in the column key object like this
	settings = {
	  columns: {
	    buildQty: {
	      title: 'buildQty'
	    },
	    created: {
	      title: 'created',
		  valuePrepareFunction: (created) => {
		    return this.datePipe.transform(new Date(created), 'dd MMM yyyy');
		  }
	    },
	    username: {
	      title: 'User Name'
	    },
	    email: {
	      title: 'Email'
	    }
	  },
	};
  1. using the date pipe in a component (NG 6+) also needs to be defined as a provider in that component . Like this
@Component({
  selector: 'xxx',
  templateUrl: './xxx.component.html',
  styleUrls: ['./xxx.component.scss'],
  providers: [DatePipe]
})
Read more comments on GitHub >

github_iconTop Results From Across the Web

Recreational Marijuana 101: How to Smoke a Pipe
Once loaded, ignite the bowl of cannabis using a lighter or hemp wick, while inhaling from the mouthpiece. If there is a carb,...
Read more >
How to Pack & Smoke a Bowl or Pipe of Weed | Leafly
Cornering can be done for all bowls—pipes and bongs. To corner a bowl, angle it down slightly and hold the flame to the...
Read more >
In The Dirt | How to Use a Pipe - Sweet Dirt
As you inhale, wait a few seconds and release your finger off the rush. Inhale the rest of the smoke inside of the...
Read more >
How to Use a Marijuana Pipe: 5 Easy Steps & Practices
1. Choose the Right Pipe · 2. Grind Up Your Weed · 3. Pack Your Bowl Lightly · 4. Cover the Pipe's Carb...
Read more >
How to Smoke Pot with a Glass Pipe | EarthMed
How to Smoke Pot with a Glass Pipe · What You'll Need: · Step 1: Grind Your Flower Before adding your weed to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found