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
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