0

In my Angular 2 app, I have a settings.js file with various exports that I want to use throughout the application:

exports.httpPort = 9000;
exports.httpsPort = 1435;
exports.segmentID = 1;

I want to export some of these into my ts component file query.component.ts, but I'm at a loss on what the correct syntax to do so is.

I see that many .js files have something along the lines of

var settings = require('../../settings'); 

which grabs the settings file and then

settings.dbConfig

Which calls the export, but it doesn't work on my component file.

This is my project file structure:

component.ts - project/web/src/app/component.ts
-Place where I want to import an export from settings.js.

settings.js - project/server/settings.js
-File where I want to make the export.

1
  • can you create a plunker? Commented Aug 11, 2017 at 16:30

1 Answer 1

0

In the component class you can do:

...
import {httpPort} from "../../../server/settings.js"
...
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.