Setup an alternative path to directories.
{
"compilerOptions": {
...
<!-- wInViewRoot directive is needed to specify the `root` for `IntersectionObserver` and some other it's options e.g. `margin` --> | |
<div class="container" wInViewRoot="viewport"> | |
Any content can be here | |
<w-in-view-item> | |
<!-- Content will be replaced by a placeholder <div> with the same height as original content. | |
Also `InViewItemComponent`s change detector will be detached when it become invisible which means | |
all the content's change detectors won't be reachable and will be inactive as well. --> | |
</w-in-view-item> | |
...or any other content can be here | |
<w-in-view-item> |
Angular has CanDeactivate
guard, but you have to declare it to each path in the routes configuration.
Valid until angular/angular#11836 will be done.
You can use CanActivateChild
guard to prevent leaving from any component with single declaration.
ControlValueAccessor
allows your component interacts with ngModel
.
Let's create a custom quantity input.
Add NG_VALUE_ACCESSOR
provider that points to component itself and implement ControlValueAccessor
interface:
import { Component, forwardRef } from '@angular/core';
In Angular we can extend the events binding syntax. Let's add posibility to log an event before firing a handler.
Create custom event plugin:
import { Injectable } from '@angular/core';
import { EventManager, ɵgetDOM as getDOM } from '@angular/platform-browser';
Template:
<ng-template #templateRef>
Popup content
</ng-template>