How to create an Angular 7+ component with two way binding ?

You have an angular component, and would like to have a value with a two way binding similar to ngModel. The easiest way is to :

  • add an Input on your document
  • add an Ouput whose name is the one of the input, suffixed by Change (that’s a required naming convention)

For example :

@Component({
  selector: 'app-select-nature-document',
  template: './select-nature-document.component.html',
  styleUrls: ['./select-nature-document.component.css']
})
export class SelectNatureDocumentComponent implements OnInit {
  @Input()
  natureDocument: NatureDocument;
  @Output()
  natureDocumentChange: EventEmitter<NatureDocument> = new EventEmitter<NatureDocument>();
...

You can then notify the value change using the output event emitter :

  onNatureDocumentSelected() {
    this.natureDocumentChange.emit(this.natureDocument);
  }

And the component can be used like this :

<app-select-nature-document [(natureDocument)]="editedDocument.nature"></app-select-nature-document>

Thanks to https://stackoverflow.com/questions/42006770/angular2-component-input-two-way-binding.

How much time do you spend coding ?

Time tracking is a pain when you have to do it for your boss, but it’s incredibly useful when you do it for you own projects, to find out what parts takes most of your time, how much time did you dedicate to this side project, etc.

For years I’ve been using Rescue time, I recently switched to https://wakatime.com, which is more programmer oriented. Its integration with VS Code (and most of the majors and not so majors IDEs) is great, and the reports really detailed.

Angular kanban component

While looking for some components to implement a kanban board, I found the @angular/cdk/drag-drop module, but I also stumbled upon this incredible work done by Trung Vo, a JIRA clone done in Angular : https://trungk18.com/experience/angular-jira-clone/, whose live demo can be seen here : https://jira.trungk18.com/project/board.

It’s so clean and neat, that you can’t help thinking “holy fuck,it’s open source ? I can use it even commercially ? I have to use it !”.

Exporting GIT history to a CSV/Excel file

There are many tools to compute stats from your GIT repositories, but sometimes, you may just want to export it to Excel and make your own quick and direty stats.

the git log command, with pretty print, is your friend. For example, the following command will display the commit date, hash, commiter name and email, and the commit message :

git log --pretty=format:%cI,%h,%an,%ae,%s > commits.csv

The pretty format documentation is available here : https://www.git-scm.com/docs/git-log#_pretty_formats