Reputation: 1867
I have created a component 'OddComponent':
export class OddComponent implements OnInit {
@Input() oddscore = 0;
constructor() { }
ngOnInit() {
}
}
And it's html is:
<div ng-if="oddscore %2 ==0 ">
<p>
odd works! {{oddscore}}
</p>
</div>
I am passing 'oddscore' variable from app component:
<app-odd [oddscore]="gameScore">
</app-odd>
My motive is to use ng-if to only print odd values in the component. But it seems that ng-if does not work as expected, as it prints all the values.
Upvotes: 1
Views: 1420
Reputation: 222682
There is no issue with the comparision, You are using angularjs syntax with angular, it should be *ngIf
<div *ngIf="oddscore%2 ==0 ">
Upvotes: 1