Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
148 views
in Technique[技术] by (71.8m points)

javascript - Keep and override settings in a config file in Angular

I have the following configuration used for a custom scrollbar settings in constants.ts file:

constants.ts:

export const COMPONENT_OPTIONS = {
    width: 5,
    height: 100,
    // other parameters
}

component.ts:

import {SCROLL_OPTIONS } from 'src/@common/constants';


//Set scroll options
this.scroll.modules = {
    component : SCROLL_OPTIONS 
}

Here is another approach where these options could be kept in an abstract class as shown below:

export abstract class Constant {

    public static COMPONENT_OPTIONS : any = {
        width: 5,
        height: 100,
        // other parameters
    }
};

My questions are:

1. In order to keep and manage the scrollbar settings in a config file, should I use the first approach (const) or the second approach (abstract class)?

2. How can I override some of the options when needed on the component side? Assume that I set default options in the base config file (constants.ts), but sometimes I need to use this config by changing height in it. In that case I cannot use const and need to find a better way. So, how can I solve this problem?

question from:https://stackoverflow.com/questions/65918411/keep-and-override-settings-in-a-config-file-in-angular

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...