Shadow DOM
In fact, Angular doesn’t use native Shadow DOM by default, it uses an emulation. Most browsers simply don’t support Shadow DOM yet, but we should still be able to use the framework. Even better, we can easily tell Angular to use the native Shadow DOM if we want, View Encapsulation in Angular.
View Encapsulation Types
Angular comes with view encapsulation built in, which enables us to use Shadow DOM or even emulate it. There are three view encapsulation types:
- ViewEncapsulation.None - No Shadow DOM at all. Therefore, also no style encapsulation.
- ViewEncapsulation.Emulated - No Shadow DOM but style encapsulation emulation.
- ViewEncapsulation.Native - Native Shadow DOM with all it’s goodness.
To make that Angular doesn’t use Shadow DOM at all. In case adding some attributes to the style so that the style is not rendered well in the browser.import {Component, OnInit, ViewEncapsulation} from '@angular/core';
@Component({
selector: 'app-period',
templateUrl: './period.component.html',
encapsulation: ViewEncapsulation.None,
styleUrls: ['./period.component.scss']
})
Bootstrap Datepicker
import {DatePickerModule} from 'ng2-datepicker'; |
<div class="col-md-3 no-padding"> |
Example of datepicker options…this.toDateOptions = {
autoclose: true,
assumeNearbyYear: true,
format: 'dd-mm-yyyy',
language: 'en',
todayBtn: 'linked',
todayHighlight: true,
weekStart: 1,
icon: 'fa fa-calendar'
};
import { ButtonsModule, DropdownModule } from 'ng2-bootstrap'; |
<div class="btn-group" dropdown> |
Simple Cache Implementation
export class TopWinnerService { |
Resource Relative Path
logo = require("../../assets/img/03.png"); |
Dynamic Base Href
<base href="./"> |
Cross Origin Problem
Add an @CrossOrigin annotation to @RestController or @RequestMapping annotated handler method in order to enable CORS on it. By default @CrossOrigin allows all origins and the HTTP methods specified in the @RequestMapping annotation, CROS Support. E.g.,
"http://domain2.com", maxAge = 3600) (origins = |
Ref: