Fix Like component to be reactive on change of nodeId parameter (#2717)

This commit is contained in:
Popovics András
2017-11-23 19:44:18 +00:00
committed by Eugenio Romano
parent 16428a8109
commit a2e6ee4c95
2 changed files with 5 additions and 3 deletions

View File

@@ -60,6 +60,8 @@ describe('Like component', () => {
}
it('should load the likes by default on onChanges', async(() => {
component.ngOnChanges();
simulateResponseWithLikes(2);
fixture.whenStable().then(() => {

View File

@@ -15,7 +15,7 @@
* limitations under the License.
*/
import { Component, EventEmitter, Input, OnInit, Output, ViewEncapsulation } from '@angular/core';
import { Component, EventEmitter, Input, OnChanges, Output, ViewEncapsulation } from '@angular/core';
import { RatingService } from './services/rating.service';
@Component({
@@ -25,7 +25,7 @@ import { RatingService } from './services/rating.service';
providers: [RatingService],
encapsulation: ViewEncapsulation.None
})
export class LikeComponent implements OnInit {
export class LikeComponent implements OnChanges {
@Input()
nodeId: string;
@@ -39,7 +39,7 @@ export class LikeComponent implements OnInit {
constructor(private ratingService: RatingService) {}
ngOnInit() {
ngOnChanges() {
this.clean();
this.ratingService.getRating(this.nodeId, this.ratingType).subscribe(