Angularjs如何返回多变量
开始学习angularjs,我正在尝试一些简单的例子。 在我的视图中,我需要2个变量total1 en total2,它们是在我的js中的一个函数中计算的 我的js 我的htmlAngularjs如何返回多变量,angularjs,model,Angularjs,Model,开始学习angularjs,我正在尝试一些简单的例子。 在我的视图中,我需要2个变量total1 en total2,它们是在我的js中的一个函数中计算的 我的js 我的html <div class="total"> <!-- Calculate the total price of all chosen services. Format it as currency. --> Totaal: <s
<div class="total">
<!-- Calculate the total price of all chosen services. Format it as currency. -->
Totaal: <span>{{total1 | currency:"€ "}}</span>
Selected: <span>{{total2 | currency:"€ "}}</span>
</div>
总计:{{total1}货币:“€”}
选定:{{total2}货币:€“}
有没有一种方法可以在视图中以角度显示变量,使用{{my_var1}}{{my_var2}}您只需要在范围中将变量作为字段公开即可
$scope.total1 = 0;
$scope.total2 = 0;
这就足够了,不需要返回任何内容。为什么需要返回这些变量??将这些变量附加到$scope,您可以在视图中访问它。将var total1=0替换为$scope.total1=0,然后执行$scope.total1+=s.price。对total2也要这样做。谢谢你的回答。我现在有点工作了
$scope.total1 = 0;
$scope.total2 = 0;