0

I have a situation whereby the below code in my viewasd

    <div class="item" *ngFor="let property of propertiesRecent; let i=index">
       <app-property [property]="property" (propertyCreated)="onPropertyCreated()"></app-property></div>

Now app-property looks something like this:

 <span class="col-lg-2 socialShare">
<fa name="share-alt" size="3"></fa>
</span>

I want to bind a jquery event on the above but once the DOM has updated after the value of propertiesRecent is updated I loose the jquery click event listner..

$('.socialShareIcons').hide()

How I do this? If you check the ngFor I tried custom event, I tried AfterViewChecked both in app-property component but did not help...

2
  • Why are you using Jquery here? Need to know more details about this question. Commented Nov 23, 2017 at 22:12
  • What element has the socialShareIcons class? Why not use angular events? Commented Nov 24, 2017 at 1:22

1 Answer 1

1

Had a similar problem, Here is a link on github with provided solution and respective discussion

In short:

<div #label *ngFor="...

Component:
Class SuperComponent {
ViewChild('label')
public label: any;
...
ngAfterViewInit() {
this.handleEndOfNgfor();
this.label.changes.subscribe(()=>this.handleEndOfNgfor());
}
private handleEndOfNgfor() 
console.log('hooray!');
}
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.