using external JS libraries in my angular 2 project

If you use angular-cli, you can add all your external JS files in assets folder. And then in angular-cli.json add them: “scripts”: [ “../node_modules/jquery/dist/jquery.min.js”, “../node_modules/bootstrap/dist/js/bootstrap.min.js”, “../node_modules/moment/moment.js”, “../node_modules/chart.js/dist/Chart.bundle.min.js”, “../node_modules/chart.js/dist/Chart.min.js”, “../node_modules/ng2-datetime/src/vendor/bootstrap-datepicker/bootstrap-datepicker.min.js”, “./assets/js/slimscroll.min.js”, “./assets/js/inspinia.js”, “./assets/js/metisMenu.js”, “./assets/js/footable.all.min.js” ] You can do it also with external styles: “styles”: [ “../node_modules/ng2-toastr/bundles/ng2-toastr.min.css”, “../node_modules/bootstrap-sass/assets/stylesheets/_bootstrap.scss”, “../node_modules/font-awesome/scss/font-awesome.scss”, “../node_modules/ng2-datetime/src/vendor/bootstrap-datepicker/bootstrap-datepicker3.min.css”, “./assets/scss/plugins/footable/footable.core.css”, “./assets/scss/style.scss” ] And of course you … Read more

How to use [(ngModel)] on div’s contenteditable in angular2?

NgModel expects the bound element to have a value property, which divs don’t have. That’s why you get the No value accessor error. You can set up your own equivalent property and event databinding using the textContent property (instead of value) and the input event: import { Component } from “angular2/core”; @Component({ selector: “my-app”, template: … Read more

How to iterate object keys using *ngFor

Angular 6.0.0 https://github.com/angular/angular/blob/master/CHANGELOG.md#610-2018-07-25 introduced a KeyValuePipe See also https://angular.io/api/common/KeyValuePipe @Component({ selector: ‘keyvalue-pipe’, template: `<span> <p>Object</p> <div *ngFor=”let item of object | keyvalue”> {{item.key}}:{{item.value}} </div> <p>Map</p> <div *ngFor=”let item of map | keyvalue”> {{item.key}}:{{item.value}} </div> </span>` }) export class KeyValuePipeComponent { object: {[key: number]: string} = {2: ‘foo’, 1: ‘bar’}; map = new Map([[2, ‘foo’], [1, … Read more