我正在创建一些非常简单的东西,它可以计算多个单选按钮的值,就像你要计算一样?已经定义了一个ng-model,以及每个收音机的值,它们在不同的屏幕上,我想在最后一个屏幕显示结果。
<ion-view title="Primeira Pergunta">
<ion-content padding="'true'" class="has-header">
<h3>Escolha a quantidade de equipamento</h3>
<form class="list">
<ion-radio ng-model="item.value" ng-value="1000">até 10</ion-radio>
<ion-radio ng-model="item.value" ng-value="2000">até 50</ion-radio>
<ion-radio ng-model="item.value" ng-value="6000">até 100</ion-radio>
<ion-radio ng-model="item.value" ng-value="5000">Franquias</ion-radio>
<ion-radio ng-model="item.value" ng-value="9000">Corporate</ion-radio>
<ion-radio ng-model="item.value" ng-value="300000">Cobertura Nacional</ion-radio>
</form>
<div class="spacer" style="width: 300px; height: 15px;"></div>
<a menu-close="" href="#/page3" class="button button-assertive button-block ">Próximo</a>
</ion-content>
<ion-view title="Segunda Pergunta">
<ion-content padding="'true'" class="has-header">
<h4>Você já o flagrou lhe observando enquanto você não estava olhando?</h4>
<form class="list"></form>
<form class="list">
<ion-radio ng-model="item.value" ng-value="30">Não</ion-radio>
<ion-radio ng-model="item.value" ng-value="70">Sim, 1 vez!</ion-radio>
<ion-radio ng-model="item.value" ng-value="100">Sim, Mais de 1 vez!</ion-radio>
</form>
<div class="spacer" style="width: 300px; height: 142px;"></div>
<a menu-close="" href="#/page4" class="button button-assertive button-block ">Próximo</a>
</ion-content>
计算结果将在这里出现:
<ion-view title="Resultado">
<ion-content padding="'true'" class="has-header">
<img src="img/AUQTMPyoQBGBfnD5HDC7_logo-portal-wp-como-conquistar-um-homem.png" width="100%" height="auto" style="width: 100%; height: auto;">
<h2>Você Fez:</h2>
<div>{{item.value}}</div>
<a href="https://e-editora.leadpages.co/leadbox/1457a340bf72a2%3A944764f46/5668783041544192/" target="_blank" style="color: rgb(255, 255, 255); text-decoration: none; font-family: Helvetica, Arial, sans-serif; font-weight: bold; font-size: 16px; line-height: 20px; display: inline-block; max-width: 300px; border-radius: 5px; background: rgb(255, 206, 10);">Clique Aqui e veja uma analise personalizada da sua nota</a>
</ion-content>
我不是专家,只是大学的工作,如何用js进行计算?
答案 0 :(得分:0)
每个问题必须有不同的ng模型。以这种方式总结模型之后:
<h2>Você Fez:</h2>
<div>{{value1 + value2}}</div>
或使用功能
<h2>Você Fez:</h2>
<div>{{ getTotal() }}</div>
$scope.getTotal = function(){
$scope.value1 + $scope.value2;
return ...
现在,如果您的离子视图位于不同的控制器上,您必须在使用AngularJs的控制器之间共享$ scope,否则您需要重新考虑问题。
见这里:http://gonzalo123.com/2014/09/08/sharing-scope-between-controllers-with-angularjs/