[英]How do I display variables passed from Express in an Angular template?
I have a variable that I passed from Express initially to a page which also uses AngularJS. 我有一个变量,最初是从Express传递给也使用AngularJS的页面的。 However when I try to access it with {{}}, it doesn't seem to appear.
但是,当我尝试使用{{}}访问它时,它似乎没有出现。 Does this only retrieve variables from the $scope?
这是否仅从$ scope检索变量? If so, how do I display other variables in AngularJS?
如果是这样,如何在AngularJS中显示其他变量?
You have to define values or constants. 您必须定义值或常量。 For example, put following code in before
</body>
. 例如,将以下代码放在
</body>
之前。
<script>
angular.module('your-module').constant('foo', 'bar');
angular.module('your-module').value('obj', {some: 1, encoded: {obj: 'xx'}});
</script>
Then you can inject foo
and obj
in your controllers/services respectively. 然后,您可以分别在控制器/服务中注入
foo
和obj
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.