T
T
TekVanDo2014-05-06 08:28:52
JavaScript
TekVanDo, 2014-05-06 08:28:52

How to configure angular application from backend?

Nothing smarter than passing parameters to a hidden input came to my mind.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mikhail Osher, 2014-05-06
@TekVanDo

As an option.

<script>
// Инжектится везде, только для чтения
angular.module('yourapp').constant('myconst', {foo: 'bar'});
// Недоступно во время конфигурации, можно инжектить во все остальные места
angular.module('yourapp').value('myvalue', ['foo', 'bar']);
</script>

// upd
If you have an application without a name (empty ng-app) - write "ng" instead of "yourapp".

K
kolesnevg, 2014-05-06
@kolesnevg

when you generate the page
add the code

<script>
window.Settings={};
Settings.var1=1;
</script>

and then in the angular code you directly access window.Settings

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question