1

I am using a base url in all my HTML pages, I want to put this base url in a fixed file and want to extract from there. How to do it in Angular JS. Can I please get the code snippet.

2 Answers 2

0

The following step could be solved your problem.

  1. You can store your all constant like URL, User, Role to constant.js file and include this file to index.html
  2. After bootstrapping your app, store into $rootScope from constant (eg. $rootScope.url = constant. Url)
  3. Enjoy it
Sign up to request clarification or add additional context in comments.

Comments

0

Just like you define your controller, you need to define constants.

app.constant('BASE_URL', 'http://www.test.com');

.controller('MyController', function (BASE_URL) {
  expect(BASE_URL).toEqual('http://www.test.com');
});

This will also help. AngularJS constants

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.