爲什麼在引導彈出窗口關閉後$scope.Templt_Kind_ID
不會更改? 注意:我不關閉彈出窗口,直到從彈出窗口中檢索下拉值。
我使用編輯控件調用引導彈出窗口。 用戶更改下拉列表值後,它會調用 的$scope.onSelectChangeTemplate_kind = function()
在下面的功能,
var ddlID = $scope.selectedCountry; contains the correct value.
$scope.Templt_Kind_ID = ddlID; // << $scope.Templt_Kind_ID = 34 as it should be
在關閉彈出窗口,我預計$scope.Templt_Kind_ID = 34
但它包含-1
這是它第一次初始化。
爲什麼? $scope.Templt_Kind_ID
應該=
的JavaScript
app.controller('APIController', function ($scope, $window, $element, $log, $http, APIService) {
$scope.Templt_Kind_ID = -1; // << Initial value
// Bootstrap popup. After dropdown in bootstrap is changed, this is called.
// I tried a number of things including $scope.onSelectChangeTemplate_kind = function ($scope)
$scope.onSelectChangeTemplate_kind = function() {
var ddlID = $scope.selectedCountry; // << contains correct value
$scope.Templt_Kind_ID = ddlID; // << $scope.Templt_Kind_ID = 34 as it should be
}
// Bootstrap popup is closed.
// Why is $scope.Templt_Kind_ID=-1 although it shuold be 34 ?????
// Why is $scope.Templt_Kind_ID=-1 although it shuold be 34 ?????
$scope.hide = function() {
console.log('model one hidden Templt_Kind_ID=' +
$scope.Templt_Kind_ID); // <<<<<<
// << $scope.Templt_Kind_ID is still -1 although it shuold be 34
$scope.showModal1 = false;
}
})
<html>
<modal-body>
<div ng-controller="APIController">
<select id="ddlSelectedCountry" ng-model="selectedCountry" ng-change="onSelectChangeTemplate_kind()">
@*3-SP Insert*@
<option value="">Select Account</option>
<option
ng-model="selectedCountry"
ng-repeat="item in list_Template_kind" value="{{item.Templt_Kind_ID}}"
>
{{item.Templt_Kind_ID}}-{{item.Templt_Kind_Name}}
</option>
</select>
</div>
</modal-body>
</html>
爲什麼你有'NG-模型=選擇的「選項」上的「selectedCountry」? –
當你在'hide()'函數中添加'console.log('隱藏一個Templt_Kind_ID ='+ $ scope.selectedCountry')模塊時,你會看到什麼? –
>>爲什麼你在選擇的選項上有ng-model =「selectedCountry」? 我討厭說,但我一直在這一天工作了一天半,不記得爲什麼我把它放在那裏。 >>當你添加console.log時,你會看到什麼('隱藏一個模型的Templt_Kind_ID ='+ $ scope.selectedCountry); -1 – JenniferWalters