generate functionMon, 05 Dec 2022

When clicking on the image display the coupon code available from the zip code

@Component({ selector: 'my-app', template: ` <input type="text" [(ngModel)]="zip" placeholder="zip code" /> <button (click)="getCoupons()">Get Coupons</button> <br /> <div *ngFor="let coupon of coupons"> <img src="{{coupon.image}}" (click)="displayCoupon(coupon.code, coupon.desc)" /> <div>{{coupon.desc}}</div> </div> `, }) export class App implements OnInit { zip: string; coupons: Coupon[]; constructor(private http: Http) {} ngOnInit() { this.http.get(`http://localhost:3000/api/coupons?zip=${}`) .map(res => res.json()) .subscribe( coupons => = coupons, err => console.log(err) );

Generate More

Questions about programming?Chat with your personal AI assistant