TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
vijay achary
NA
38
1.1k
How to passing value customdirective to anothere component
Nov 16 2017 1:42 AM
In angular2
================
custom Directive
===============
import { Directive, ElementRef, HostListener, Input,Output,EventEmitter } from '@angular/core';
import { Pipe, PipeTransform } from '@angular/core';
import { DatePipe } from '@angular/common';
@Directive({
selector: '[CustomDirCurrentTime]'
})
export class CustomDirCurrentTime {
@Output() ngModelChange = new EventEmitter();
finalData: string='';
format: string = 'hh:mm';
constructor(private el: ElementRef) {
var datePipe = new DatePipe("en-US");
var Data = datePipe.transform(new Date(), this.format);
-->this.el.nativeElement.value = Data.toString();
this.ngModelChange.emit(this.el.nativeElement.value);
this.el.nativeElement.maxLength = 5;
}
@HostListener('change', ['$event']) onKeyDown(event) {
let GetLegth = this.el.nativeElement.value;
}
}
my component
==========
import { ActivatedRoute } from '@angular/router';
import { FormsModule } from '@angular/forms';
import { Component, OnInit, Input, EventEmitter } from '@angular/core'
@Component({
selector: 'erp-modules',
styleUrls: ['../../../../assets/css/masters/masters.css'],
templateUrl: './ERPModules.html',
})
export class ERPModuleComponent {
@Input() ngModelChange = new EventEmitter();
data: any = [];
Get(e)
{
var kk = this.data;
}
Set()
{
var kkkk = this.data;
}
}
I need custom directive value which is --> marked that is "data" sending my component.how to send from custom directive to my component
Reply
Answers (
2
)
File Upload :saving file in our Visual code under one Folder
How can i append checkbox value to checkbox in angularJS