0
<configuration>
    <appSettings>
            <add key="var1" value="SomeValue"/>
      </appSettings>
<configuration>

I want to read this var1 in angularJS controller Like this...

function ReadConfigurationSettings()
    {
        var k = '<%=ConfigurationManager.AppSettings["var1"].ToString() %>'
        alert(k);
    }

but its not working..

1 Answer 1

1

You cannot get a value from web config directly. One option is to put the value into a meta tag in your index html for example like this:

<meta name="var1" content="@ConfigurationManager.AppSettings["var1"]" />

Then you can get that value from angular like this:

var var1 = angular.element(document).find('meta[name=var1]').prop("content");
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.