0

I have some data which come from serverside and cannnot be harcoded in js. I was thinking of rendering them as data attribute in HTML and get that back to angular javascript but cannot figure how to?

I've read this question in stack overflow which suggest to pull data through $http.get('serversideurl'). But I don't want to make another serverside request again.

Another suggestion was to put the data as global variable (eg somewhere in in window scope)

I would like to ask if it is possible to pull data directly from html data attribute, which I see convenient at the moment.

Is there any better way to do this? What approach is recommended?

1 Answer 1

0

Did you also take a look at the second answer of your linked question https://stackoverflow.com/a/13775151/669561? You could accomplish it via ngInit

But the approach I would recommend is fetching the data through an additional HTTP-Request. Is there a technical reason why you don't want to make another server request?

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

1 Comment

Thanks for pointing.yes, it is a heavy serverside processing involving external api request, why doing the same job again. stackoverflow.com/questions/11763263/… Do you think we can achieve the same like in second answer to above question?

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.