Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

import { Directive, OnChanges, HostBinding } from @angular/core; import { NgOnChangesFeature } from '@angular/core/src/render3'; enum CardType { VISA = 'Visa' ,MASTERCARD = 'MasterCard',DISCOVER = 'Discover'

import { Directive, OnChanges, HostBinding } from "@angular/core";

import { NgOnChangesFeature } from '@angular/core/src/render3';

enum CardType { VISA = 'Visa' ,MASTERCARD = 'MasterCard',DISCOVER = 'Discover' ,UNKNOWN = 'Unknown'

@ Directive ({

selector:'[cLogo]'

})

export class CreditCardImageDirective implements OnChanges {

@HostBinding ('src')

imageSource;

cardNumber: number;

NGOnChangesFeatures ;

this.imageSource = ('') ;

if (this.cardnumber) {

if (this.cardnumber.startsWith('4')) {

return cardTypeType.Visa;

} else if (this.cardnumber.startsWith('5')) {

return cardType.MasterCard;

} else if (this.cardnumber.startsWith ('60')) {

return cardType.Discover;

}

}

return cardType.Unknown ;

NGOnChangesFeatures;

this.imageSource = 'assets/card-types/' +

this.getCardTypeFromNumber () + '.png' ;

Please fix this code to get the output - attribute directives to display credit card logo based on the credit card number- in Angular

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases And Python Programming MySQL MongoDB OOP And Tkinter

Authors: R. PANNEERSELVAM

1st Edition

9357011331, 978-9357011334

More Books

Students also viewed these Databases questions

Question

What are the different techniques used in decision making?

Answered: 1 week ago

Question

Who or what is affected by this situation?

Answered: 1 week ago

Question

How important is this situation to the organizations mission?

Answered: 1 week ago