0
<select id="CFG_USERS_DFTLEVEL" name="CFG_USERS_DFTLEVEL" ng-options="obj.CFG_ORGLEVEL_ID as obj.CFG_ORGLEVEL_CODE for obj in items" ng-model="formData.CFG_USERS_DFTLEVEL">
<option value="">Select Default Org Level</option></select>
HTML Code above
靜態值工作dood..But動態的Json值不工作爲什麼動態選擇框json值不工作?
數據響應輸出:
{"orglevel":[{"CFG_ORGLEVEL_ID":"1","CFG_ORGLEVEL_CODE":"AEB"},{"CFG_ORGLEVEL_ID":"2","CFG_ORGLEVEL_CODE"
:"MTL"},{"CFG_ORGLEVEL_ID":"3","CFG_ORGLEVEL_CODE":"TOR"}]}
控制器代碼在這裏:
$http.post('test/test.php',userdata).success(function(data) {
var jsondata = JSON.stringify(data['orglevel']);
/* static value work fine*/
//$scope.items = [{ "CFG_ORGLEVEL_ID": 1, "CFG_ORGLEVEL_CODE": "AEB" }, { "CFG_ORGLEVEL_ID": 2, "CFG_ORGLEVEL_CODE": "MTL" }, { "CFG_ORGLEVEL_ID": 2, "CFG_ORGLEVEL_CODE": "TOR" }];
$scope.items = jsondata ; //not working
});
嘗試使用'JSON.parse()來'如果你想把它當作一個數組 – AndersRehn
太謝謝你了...它工作正常...謝謝 – shunmugarajan