angular2-hostbinding

Apply attribute directive on component in Angular 4

孤街浪徒 提交于 2020-08-04 04:43:44
问题 I have created img-pop component which has @Input() bind property src. I have created authSrc directive which has @HostBinding() property src. @Component({ selector: 'img-pop', template: `<img [src]="src"/> <div *ngIf="isShow"> <----extra value-----> </div>` }) export class ImgPopOverComponent implements OnInit { @Input() private src; private isShow=false; @HostListener('mouseenter') onMouseEnter() { this.isShow= true; } @HostListener('mouseleave') onMouseLeave() { this.isShow= false; } } I

onbeforeunload confirm dialog not showing when angular2 @HostListener is used

久未见 提交于 2020-01-19 14:12:45
问题 Using @HostListener hook, but confirm dialog (that asks: Do you want to Leave this page? ...or Do you want to Reload this page?) is not showing. The code works, but the confirm dialog is not showing. Here what I have: @HostListener('window:beforeunload', ['$event']) public doSomething($event) { console.log("do I see this?") // <---- this logs to the console. return "something else"; } But I don't see this: 回答1: returning false instead of the string "something else" fixes the problem and the

onbeforeunload confirm dialog not showing when angular2 @HostListener is used

青春壹個敷衍的年華 提交于 2020-01-19 14:11:27
问题 Using @HostListener hook, but confirm dialog (that asks: Do you want to Leave this page? ...or Do you want to Reload this page?) is not showing. The code works, but the confirm dialog is not showing. Here what I have: @HostListener('window:beforeunload', ['$event']) public doSomething($event) { console.log("do I see this?") // <---- this logs to the console. return "something else"; } But I don't see this: 回答1: returning false instead of the string "something else" fixes the problem and the

Angular 2: Get position of HTML element

 ̄綄美尐妖づ 提交于 2019-12-12 10:56:58
问题 I'm trying to implement a custom directive in Angular 2 for moving an arbitrary HTML element around. So far everything is working except that I don't now how to get the initial position of the HTML element when I click on it and want to start moving. I'm binding to the top and left styles of my HTML element with those two host bindings: /** current Y position of the native element. */ @HostBinding('style.top.px') public positionTop: number; /** current X position of the native element. */

Use @HostBindings instead host in angular 4

て烟熏妆下的殇ゞ 提交于 2019-12-04 12:18:53
问题 I just try to make animation with angular 4 and I saw tutorial that use host in the component import { Component, OnInit, HostBinding } from '@angular/core'; import { AngularFire, AuthProviders, AuthMethods } from 'angularfire2'; import { Router } from '@angular/router'; import { moveIn } from '../router.animations'; @Component({ selector: 'app-login', templateUrl: './login.component.html', styleUrls: ['./login.component.css'], animations: [moveIn()], host: {'[@moveIn]': ''} }) but it shows

Inject Style Declarations Using Hostbinding in Angular

左心房为你撑大大i 提交于 2019-11-28 01:11:38
问题 Do you guys know how I can batch inject style declarations in a component using the @HostBinding decorator? What I am trying is: @HostBinding('style') get style(): CSSStyleDeclaration { return { background: 'red', color: 'lime' } as CSSStyleDeclaration; } In my understanding this should inject the background and color style to the component, but it does not... I can control individual style declarations like this: @HostBinding('style.background') private background = 'red'; but I would like