Add Custom Icon in Ionic 2

This is the easiest way I’ve found, from the forums at https://forum.ionicframework.com/t/anyway-to-custom-the-tabbars-icon-with-my-own-svg-file/46131/36. In your app.scss file, add the following code: ion-icon { &[class*=”appname-“] { // Instead of using the font-based icons // We’re applying SVG masks mask-size: contain; mask-position: 50% 50%; mask-repeat: no-repeat; background: currentColor; width: 1em; height: 1em; } // custom icons &[class*=”appname-customicon1”] { … Read more

Cannot find namespace NodeJS when using NodeJS.Timer in Ionic 2

Open src/tsconfig.app.json*. Add “node” to the “types” array. Example: { “extends”: “../tsconfig.json”, “compilerOptions”: { “outDir”: “../out-tsc/app”, “baseUrl”: “./”, “module”: “es2015”, “types”: [ “node” ] }, “exclude”: [ “test.ts”, “**/*.spec.ts” ] } *if this file does not exist add the specified part to tsconfig.json in root folder.

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

Safe value must use [property]=binding after bypass security with DomSanitizer

As the error message says, the sanitized HTML needs to be added using property binding: <p [innerHTML]=”massTimingsHtml”></p> constructor(private domSanitizer:DomSanitizer) { this.massTimingsHtml = this.getInnerHTMLValue(); } getInnerHTMLValue(){ return this.domSanitizer.bypassSecurityTrustHtml(this.parishDetail.mass_timings); } StackBlitz example (based on Swapnil Patwa’s Plunker – see comments below)

How to convert date into this ‘yyyy-MM-dd’ format in angular 2

The date can be converted in typescript to this format ‘yyyy-MM-dd’ by using Datepipe import { DatePipe } from ‘@angular/common’ … constructor(public datepipe: DatePipe){} … myFunction(){ this.date=new Date(); let latest_date =this.datepipe.transform(this.date, ‘yyyy-MM-dd’); } and just add Datepipe in ‘providers’ array of app.module.ts. Like this: import { DatePipe } from ‘@angular/common’ … providers: [DatePipe]

Ionic directives VS Angular material directives with Ionic Framework

I found a material design CSS framework known as Materializecss. It looks promising. It’s just plain CSS and javascript framework. http://materializecss.com/ Advantages over other frameworks Pure CSS classes, will not conflict with ionic directives. No performance loss. Of all the frameworks I have seen, this is the only one closely following material design rules Almost … 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