我已经使用 AngularJS 开发了一个前端应用程序来访问 REST 端点。我为此使用 $resource 。现在,我想从我的项目类路径上的 .properties 文件中读取 url(针对该端点),而不是将其硬编码到 Controller 中。我该如何着手实现这一目标?
最佳答案
假设您将属性存储在 url.properties 文件中。
var app = angular.module('app', []);
app.controller('test', function ($scope, $http) {
$http.get('url.properties').then(function (response) {
console.log('value1 is ', response.data.value1);
console.log('value2 is ', response.data.value2);
});
});
您将获得response.data 中的所有属性。*
关于java - 使用 angularJS 从存储在 Eclipse 项目类路径中的 .properties 文件中提取值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24281792/