我想要做的是,當我將鼠標懸停在「點擊我」按鈕,然後它應該顯示在網頁上的圖像,當我unhover它不應該顯示出與鼠標懸停選項的幫助下如何在angularjs2中通過鼠標懸停選項將鼠標懸停在按鈕上,從而將圖像閃爍?
這裏是任何圖像我試圖app.component.ts和my.component.ts做文件
這裏是app.component.ts代碼:
import { Component } from '@angular/core'; //importing components from angular
import { MyComponent } from './my.component'; //importing components from my.component
@Component({
selector: 'my-app',
template: `<h1> Hi Buddy!! </h1>
<mytag></mytag>`,
directives: [MyComponent] //adding directives from mycomponents
})
export class AppComponent { }
這裏是my.component的代碼。 ts:
import { Component } from "@angular/core";
@Component({
selector:'mytag',
template: `<button (mouseover)="<img [src]="image"> " >click me</button>` // here i tried to flash image by hovering
})
export class MyComponent{
public image="http://lorempixel.com/400/200";
myclick(klm){
console.log(klm);
}
}
因此,我應該在my.component.ts的類或元數據中進行哪些更改才能做到這一點