錯誤截圖
錯誤描述:非select2插件元素可正常回寫,但select2插件干涉的顯示框無法正常回寫。
錯誤原因分析
分析:直接請求數據庫返回結果如圖
我們衝數據庫讀到的信息爲字符串,而select2插件的配置是要一個json對象
解決方案
在controller層–>angularJs
處理返回數據結果,將其解析爲Json對象
//查詢實體
$scope.findOne=function(id){
typeTemplateService.findOne(id).success(
function(response){
$scope.entity= response;
//處理返回數據結果,解析爲Json對象
$scope.entity.customAttributeItems = JSON.parse(response.customAttributeItems)
$scope.entity.specIds = JSON.parse(response.specIds)
$scope.entity.brandIds = JSON.parse(response.brandIds)
}
);
}