Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How get a value of id from template of another Component angular2 #88

Open
khalildiouriadservio opened this issue Jul 8, 2016 · 1 comment

Comments

@khalildiouriadservio
Copy link

khalildiouriadservio commented Jul 8, 2016

I need to get an ID of a tag

from another Component template
  <li id="form" (onDragStart)="getDraggableId($event)">Form</li>
in typescript file(component) I have this

 getDraggableId(event) {
        this.gridService.setDraggabledIdGrid(event.mouseEvent.target.id);
        console.log("event  " + this.gridService.getDraggabledIdGrid());

    }

how can I get event.mouseEvent.target.id

I tried to create a service gridService to intermediate between the two components

@Injectable()
export class gridService {
    draggableIdGrid:string;

    constructor() {

    }
    getDraggabledIdGrid():string{
        return this.draggableIdGrid;
    }
    setDraggabledIdGrid(value){
        this.draggableIdGrid = value;
    }
}

but when I call the method getDraggableIdGrid I get undefuned value

@neokoenig
Copy link
Owner

neokoenig commented Jul 8, 2016

Sorry, I have zero experience with Angular.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants