0

I have a project where I build a static web just for diplaying items. I don't have backend system so I just use Angular to display list of items from js. I want user able to update their item from js without re-compiling the angular app.

here is my sample https://stackblitz.com/edit/mockdatatestangular?embed=1&file=src/app/app.component.html

in here I have mockupdata.ts where I store all data that need to be displayed. I want this to be editable / renewable (I mean I can just upload new mockupdata.ts to server without re compile the entire app).

Is it possible to do that ?

1 Answer 1

1

When you compile your Angular code, you turn it into JS code in one or more JS files. Your Angular app can't "read" from a TypeScript file. It's not dynamic in that way. In the process you're describing, your data is hardcoded in the final bundle.

What you might try doing is uploading your data in a JSON file and reading it from there, as long as your server allows for it. If not, you'll need some basic server which can return your data as JSON.

Sign up to request clarification or add additional context in comments.

2 Comments

i can change it into js by removing class name on mockupdata. the reason I won't use backend because it is easier for user to update on excel and i will convert it to js data and then upload it. also I use cheap webhosting so I don't thinj I need to create the backend for it
If you can upload as JSON and read it as is, then it should be fairly simple, especially as converting from an Excel spreadsheet or CSV to JSON is normally quite easy. As far as I know, you can't make your Angular app read a JS file in the way you're describing.

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.