I have several select list in my form HTML where we are gathering user inputs.
Here is what I want to do 1) Initially disable 'select' list by using ng-disabled='true' as there is no data ready in controller because I am getting data from Server in async way. 2) When the async call is successfully made, I want to enable the 'select' control so that it can populate the data (from server) to users.
Problem is it doesn't work :( Please take a look at the codes below and help me resolving this.
$scope.isNeedDisable = true;
// Retrieving Market List
$scope.retrieveMarketList = function () {
var sql = "SELECT marketlist from market_table";
var dataLoader = xxx.data.loader
.Builder
.fromSql(sql)
.build();
var dataSet = new xxx.data.DataSet()
.dataLoader(dataLoader);
dataSet.fetch(new xxx.data.Projection()).then(function(d) {
$scope.jsonMarketList = d[0].data;
$scope.isNeedDisable = false;
}, onDataError);
};
<form class="form-horizontal" role="form" action="index_org.html" method="GET" id="mSpeedOneForm">
<div class="form-group">
<label for="AccountMarket" class="col-lg-2 control-label">Market</label>
<div class="col-lg-10">
<select id="accountMarketList"
name="accountMarket"
class="selectpicker show-tick form-control"
data-live-search="true"
ng-model="selectedMarket"
ng-options="market.country for market in jsonMarketList"
ng-required="true"
ng-disabled="isNeedDisable">
<option value="">Select market you want</option>
</select>
</div>
</div>
<form>
I debugged the code with WebStorm and found out all the data is successfully retrieved and 'isReady' value is changed correctly to 'true'.
But the select list is still disabled. What is wrong with my code?
Thanks in advance.