angularjs - Configure automatically Angular value provider -
my angular spa app has value provider. provider injected controllers. @ deployment time, manually comment/uncomment value used. wonder if there way automatically toggle values base on web.config mechanism? thanks.
'use strict'; // demonstrate how register services // in case simple value service. angular.module('myapp.services', []) .value('version', '5.0') //local iis7 //.value('mywebapiendpoint', 'http://localhost/cmt data service/api/') //staging iis .value('mywebapiendpoint', 'https://staging.myorg.org/wcf_webapi/data%20service/api/') //production iis //.value('mywebapiendpoint', 'https://production.myorg.org/wcf_webapi/data%20service/api/')
instead of using hard coded value, add following angular value provider module in _layout.cshtml
<script> angular.module("myapp.services") .value("version", '@system.configuration.configurationmanager.appsettings["appversion"]') .value("webapi1endpoint", '@system.configuration.configurationmanager.appsettings["webapi1endpoint"]') .value("webapi2endpoint", '@system.configuration.configurationmanager.appsettings["webapi2endpoint"]') </script>
section in _layout.cshtml
Comments
Post a Comment