0

config.js

angular.module("steam")

.value("config", {
  baseurl: "http://dev-back1.techgrind.asia/"
});

I have to access the value outside the module by replacing the "http://dev .." with config.baseurl

test.js

var frisby = require("frisby");

frisby.create("Status test")
  .get("http://dev-back1.techgrind.asia/scripts/rest.pike?request=test")
  .expectStatus(200)
  .toss();

4
  • i don't really understand the question, but i think you are searching for $scope docs.angularjs.org/guide/scope Commented Jul 23, 2015 at 13:38
  • No. Look at config.js . Anywhere inside the module, I can access the value by calling config.baseurl . But, test.js is outside the module and I want to access config.baseurl here. How to? Commented Jul 23, 2015 at 13:45
  • ensure that config.js is loaded before test.js - and then there are multiple ways - you could save it directly in the browser (as a global JS variable) or you use the angular conform way and create a service / factory which returns your config data. Thats the way i would try Commented Jul 23, 2015 at 13:49
  • if you use a restful server you could let your config factory ask for the configs and then you just need to inject the "Config" object into your angular controllers - do you know how to do this? Commented Jul 23, 2015 at 13:51

1 Answer 1

1

You might reach outside the module like these. But in my opinion use .constant instead of .value for constant rest endpoints etc.

var config = angular.injector(["ng", "module"]).get("config");
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.