angularjs:如何将web.config中的数据带到视图控制器?

nkcskrwz  于 2021-09-29  发布在  Java
关注(0)|答案(2)|浏览(255)

如何将数据从web.config带到视图控制器(.controller.js)?非常感谢。

u4dcyp6a

u4dcyp6a1#

添加信息。
web.config:

<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
      <section name="HHH.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    </sectionGroup>
  </configSections>
  <appSettings>

    <add key="webpages:Version" value="3.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />

    <add key="querytime" value="6000"/>
    <add key="offsettime" value="86400"/>
    <add key="alarmarmingtime" value="300"/>

  </appSettings>

...

在.controller.js中,我尝试了以下方法:

vm.radiationPresent = function () { 

            $http.get('/api/radiation/GetAlarmRad').then(function (response) {
                if (response.data == true) {
                    console.log('radiationPresent parte V');
                    return alert('Evento de radiación!!');
                } else {
                    console.log('radiationPresent parte F');
                    return alert('No hay evento de radiación...');
                }

            })
        };

        //$interval(vm.radiationPresent, 6000); 
        $interval(vm.radiationPresent, Convert.ToInt32(ConfigurationManager.AppSettings["offsettime"]));

但它不识别“convert”或“configurationmanager”

w9apscun

w9apscun2#

谢谢你,国王!我能够实现您传递给我的解决方案。
anthonychu.ca/post/how-to-pass-webconfig-settings-to-angularjs

相关问题