I have a function and it's being used in different components. To use it across few components, i am pasting the same code in each component. I want to create a lib, in which i will write this method and then import it across the components. Please suggest a way how to approach.
@Component({
// Some metadata
})
export class ComA {
dataValid(val: any): string {
// some login
}
}
@Component({
// Some metadata
})
export class ComB {
dataValid(val: any): string {
// some login
}
}
Here i am using dataValid() function repeatedly.
I want some thig like
@Component({
// Some metadata
})
export class ComA extends GenericLib {
}
@Component({
// Some metadata
})
export class ComB extends GenericLib {
}
And use dataValid() function in GenericLib class