by joe.pesch
16. February 2018 15:08
Issue with component level styles not working, import "ViewEncapsulation: from @angular/core and add encapsulation: ViewEncapsoulation.None to the @Component decorator as shown below.
import { Component, OnInit, ViewEncapsulation } from '@angular/core';
@Component({
selector: 'app-demo',
templateUrl: './demo.component.html',
styleUrls: ['./demo.component.css'],
encapsulation: ViewEncapsulation.None
})
by joe.pesch
16. February 2018 15:00
Navigate a JSON object by a dotted string path (e.g. "somePath.subPath.anotherSubPath").
console.log('somePath.subPath.anotherSubPath'.split('.').reduce((o, i) => o[i], jsonObject));
by joe.pesch
16. February 2018 14:56
Take a dotted string (e.g. "someThing.someThingElse.another") and convert first letter of each dotted component to upper or lower case.
dottedToUpper(str) {
str = str.replace(/\./g, ' ');
str = str.replace(/\w\S*/g, function (txt) {
return txt.charAt(0).toUpperCase() + txt.substr(1);
});
return str.replace(/ /g, '.');
}
dottedToLower(str) {
str = str.replace(/\./g, ' ');
str = str.replace(/\w\S*/g, function (txt) {
return txt.charAt(0).toLowerCase() + txt.substr(1);
});
return str.replace(/ /g, '.');
}