.controller('mainCtrl', ['$scope', '$http', function($scope, $http){
$scope.wales_total = function(){
$select_7 = parseInt($(".select_7 strong").html().replace(',' , ''));
console.log($select_7);
$welsh_total = Number($select_7 ||0);
return $welsh_total;
};
$scope.scotland_total = function(){
$select_8 = parseInt($(".select_8 strong").html().replace(',' , ''));
$total = Number($select_8 ||0);
return $total;
};
$scope.ireland_total = function(){
$select_9 = parseInt($(".select_9 strong").html().replace(',' , ''));
$total = Number($select_9 ||0);
return $total;
};
$scope.totals_test = $(".total").html();
HTML:
<div ng-switch-when="NHS Wales Health Board">
<div class="col-sm-6 col-sm-offset-3">
<form>
<label class="pull-left">Health Board</label>
<select ui-select2 class="form-control select_2nd" ng-model="selectedOption_7" ng-options="data as data.displayName for data in wales_data"></select>
<div class="population_estimate_wrapper">
<p class="population_estimate">Population Estimate</p>
<div class="population_estimate_box" ng-model="selectedOption_7">
<p class="hidden select_7"><strong>{{selectedOption_7.value}}</strong></p>
<p class="total" ng-model="total">{{wales_total()}}</p>
</div>
</div>
</form>
</div>
</div>
<div ng-switch-when="NHS Scotland Health Board">
<div class="col-sm-6 col-sm-offset-3">
<form>
<div class="form-group">
<label class="pull-left">Health Board</label>
<select ui-se-lect2 class="form-control select_2nd" ng-model="selectedOption_8" ng-options="data as data.displayName for data in scotland_data"></select>
<div class="population_estimate_wrapper">
<p class="population_estimate">Population Estimate</p>
<div class="population_estimate_box" ng-model="selectedOption_8">
<p class="hidden select_8"><strong>{{selectedOption_8.value}}</strong></p>
<p class="total">{{scotland_total()}}</p>
</div>
</div>
</div>
</form>
</div>
</div>
<div ng-switch-when="Northern Ireland Health And Social Services Board">
<div class="col-sm-6 col-sm-offset-3">
<form>
<div class="form-group">
<label class="pull-left">Health Board</label>
<select ui-select2 class="form-control select_2nd" ng-model="selectedOption_9" ng-options="data as data.displayName for data in ireland_data">
<option selected value>Select</option>
</select>
<div class="population_estimate_wrapper">
<p class="population_estimate">Population Estimate</p>
<div class="population_estimate_box" ng-model="selectedOption_9">
<p class="hidden select_9"><strong>{{selectedOption_9.value}}</strong></p>
<p class="total">{{ireland_total()}}</p>
</div>
</div>
</div>
</form>
</div>
</div>
然后我们有一个隐藏显示功能,它将隐藏上面的部分,并显示当前隐藏的代码。
HTML2:
<div class="main_container_wrapper">
<div class="main_container">
<div class="budget_row odd bg_lines_1">
<p class="blue size15"><strong>Primary non-familial hypercholesterolaemia or mixed dyslipidaemia</strong></p>
<div class="row_left">
<p class="grey size13"><strong>Total catchment population</strong></p>
</div>
<div class="row_right text-center">
<p class="number_box">{{totals_test}}</p>
</div>
</div>
所以基本上,无论什么html在class =“total”中都应该转储到$ scope.totals_test变量中。我想要做的是,如果我回到previos页面,并更改html,有角度更新,当我再次前进。 (它全部在一个页面上,只显示和隐藏不同的部分)
答案 0 :(得分:0)
你可以使用ng-show来显示show hide而不是调用jquery,jquery不在AngularJS的摘要中
也使用这样的东西:$ scope.number.show ...如果你像这样使用hirerichy,它会反映在控制器中..我不知道为什么,但它有效
答案 1 :(得分:0)
我无法完全理解您的要求,但我相信您正在寻找以下的视图和控制器。
<强> HTML 强>
<div ng-if="!showParagraph">
<p>{{number()}}</p>
<button ng-click="show">Click Me</button
</div>
<div class="example_2" ng-if="showParagraph">
<p ng-bind="number()"></p>
</div>
<强> CONTROLLER 强>
$scope.show= function() {
$scope.showParagraph = true;
};
$scope.number = function() {
5 * 5
};