0
"getv"関数が実行されないのはなぜですか?私は、ドロップダウンリストを通じて値を取得し、カスタムディレクティブで角2 - 出力関数を実行しません。
私の作業plnkrを、その値を放出しようとしています: https://plnkr.co/edit/dIVY8QSyng5naFOBK8uB?p=preview
Home.html
<div>
<header [showCaps]="texttransform" (getmodifed)="getv($event)">This is header</header>
<div>This is mainarea</div>
<footer>THis is footer</footer>
<select (change)="getOptionValue($event.target.value)">
<option data-value="uppercase">Uppercase</option>
<option data-value="lowercase">Lowercase</option>
</select>
</div>
Scrpit.ts
import {Component,NgModule,Input,Output,EventEmitter,Directive,ElementRef,Renderer,ViewEncapsulation,AfterViewInit} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
@Component({
selector:'firstapp',
templateUrl:'./home.html'
})
class firstappComponent{
public headingtitle:string='Dynamic Heading Title';
public texttransform:string="uppercase";
@Output() getmodifed=new EventEmitter();
getOptionValue=function(getit){
this.getmodifed.emit(getit);
}
}
@Directive({
selector:'[showCaps]'
})
class showCapsDirective implements AfterViewInit{
@Input('showCaps') getdata;
constructor(private el:ElementRef,private render:Renderer){}
getv=function(data){
console.log(data);
this.render.setElementStyle(this.el.nativeElement,'text-transform',this.data)
}
}
@NgModule({
imports:[BrowserModule],
declarations:[firstappComponent,showCapsDirective],
bootstrap:[firstappComponent]
})
class app{}
platformBrowserDynamic().bootstrapModule(app)
感謝を参照してください! –
あなたのご歓迎ありがとうございましたらお知らせください。 –