AngularJS Scope vs. Bind

时间:2015-02-03 10:14:28

标签: javascript angularjs angularjs-scope ng-bind

我对这个问题感到好奇:

在MainController中我有这个:

$scope._layout = { currentYear: moment().format('YYYY') };

在html布局页面中,我有这个。

[...]

<body class="" ng-controller="MainController">

<!-- BEGIN PAGE CONTAINER-->
{% block content %}{% endblock %}
<!-- END CONTAINER -->

<span>{{_layout.currentYear}}</span>

[...]

上面这个不起作用,{{_ outputout.currentYear}}什么也没有显示,但是如果我把它改成ng-bind,那么它就可以了。

[...]

<body class="" ng-controller="MainController">

<!-- BEGIN PAGE CONTAINER-->
{% block content %}{% endblock %}
<!-- END CONTAINER -->

<span ng-bind="_layout.currentYear"></span>

[...]

为什么{{_layout.currentYear}}语法不起作用?

0 个答案:

没有答案