angularjs read from properties file
Simple way is to
create a js file named
"config.js" (lets assume in the path scripts/config/config.js)
config.js:
var test1="http://testurl.com" var test2="globalconstant"
In the html page include this config.js at the top (above the main controller.js):
**<script.. src="./scripts/config/config.js"></st>**
In the controller make the following change:
MainController.js: $scope.appUrl = test1; $scope.appConstant = test2;
If connection.properties
is a file that lives on your web server, then you simply need to do this:
var app = angular.module('app', []);
app.controller('test', function ($scope, $http) {
$http.get('connection.properties').then(function (response) {
console.log('a is ', response.data.a);
console.log('b is ', response.data.b);
});
});
You can see an example here:
http://plnkr.co/edit/3Ne3roFOwcfVmg2mgnUr?p=preview