次のような rootScope 変数を作成しました
$rootScope.globalData = data;
$rootScope.globalData.chillerConditions.HeatSource.Value = "ST"; //Default Value
$scope.chillerConditions.HeatSource.Value = 1; //Default Value
data
APIからの戻り値はどこにありますか。また、アイテムのリストを含むオブジェクトであるスコープ変数を作成します。
$scope.chillerAttributes = data.ObjCandidateListChillerAttributes;
$scope.chillerConditions = data.ObjCandidateListConditions;
HTMLには次のものがあります:
<select ng-model="chillerConditions.HeatSource.Value" style="width:53%;" ng-options="item.Id as item.Description for item in ValidRatingHeatSource" ng-change="heatSourceChanged()" id="ddRatingHeatSource" class="form-control search-select designComboboxHeight" data-container="body"></select>
ここValidRatingHeatSource
は
$scope.ValidRatingHeatSource = \*list of items*\
ドロップダウンの変更時に、関数を作成しました。その中で
if($scope.chillerConditions.HeatSource.Value == 2)
{
$rootScope.globalData.chillerConditions.HeatSource.Value = "HW";
}
else
{
$rootScope.globalData.chillerConditions.HeatSource.Value = "ST";
}
今までは私の現在のコードでした。問題は次のとおりです。
上記の関数が呼び出されると、現在の$rootScope
変数 ie$rootScope.globalData.chillerConditions.HeatSource.Value
が に変更されるか、"HW"
または"ST"
にも変更$scope.chillerConditions.HeatSource.Value
され"HW"
ます"ST"
。
なんでそうなの?
angularjsに組み込みの機能はありますか? 私が間違いを犯している場合は提案してください。新しい提案も大歓迎です。