Why is $scope.Templt_Kind_ID
not changing after the bootstrap popup is closed?
Note: I do not close the popup until I retrieve the dropdown value from the popup.
I call a bootstrap popup with edit controls.
After a user changes a dropdown value, it calls
the $scope.onSelectChangeTemplate_kind = function ()
In the function below,
var ddlID = $scope.selectedCountry; contains the correct value.
$scope.Templt_Kind_ID = ddlID; // << $scope.Templt_Kind_ID = 34 as it should be
Upon closing the popup, I expected $scope.Templt_Kind_ID = 34
but it contains -1
which is what it was first initialized to.
Why? $scope.Templt_Kind_ID
should = 34
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>