我正在尝试学习 AngularJS 的基础知识,并尝试在数字足够大时使文本可见。看起来 more() 函数只在页面第一次显示时调用一次。 lessThan3() 函数返回正确的值,但在尝试 ng-hide 时不起作用。
AngularJS
function ApplicationController($scope,$interval) {
$scope.number = 0;
$interval(function() {
$scope.number++;
}, 1000);
$scope.lessThan3 = function(){
return ($scope.number < 3);
}
}
HTML
Number: {{ number }}
{{ lessThan3() }}
<p ng-hide="{{ lessThan3 }}">
Less than 3
</p>
最佳答案
只是
<p ng-show="more()">
对于 jsfiddle,或
<p ng-hide="lessThan3()">
这里的例子。
没有{{}}
关于javascript - 从 AngularJS 更新 html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40556130/