Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!