BUG——AngularJS:Cannot set property ‘pic‘ of undefined
一、異常
TypeError: Cannot set property ‘pic’ of undefined
at contentController.js:87
at angular.min.js:62
at C (angular.min.js:88)
at C (angular.min.js:88)
at angular.min.js:90
at h.
e
v
a
l
(
a
n
g
u
l
a
r
.
m
i
n
.
j
s
:
98
)
a
t
h
.
eval (angular.min.js:98) at h.
eval(angular.min.js:98)ath.digest (angular.min.js:96)
at h.$apply (angular.min.js:99)
at f (angular.min.js:63)
at E (angular.min.js:67)
二、程式碼
//上傳廣告圖
$scope.uploadFile=function(){
uploadService.uploadFile().success(
function(response){
if(response.success){
$scope.entity.pic=response.message;
}else{
alert("上傳失敗!");
}
}
).error(
function(){
alert("上傳時發生異常!");
}
);
}
報錯の地方——$scope.entity.pic=response.message;
三、解釋
列印一下entity發現,報一樣得錯誤Cannot set property ‘entity’ of undefined
說明,entity就沒初始化
四、解決
新增一句程式碼即可——
$scope.entity={};//定義頁面實體結構
js中一般是直接賦值即可,但是entity都沒有,你想給它的屬性pic賦值,就顯得荒誕了!!!
相關文章
- Cannot read property ‘aDataSort‘ of undefinedUndefined
- 使用req.session.xxx時出現 Cannot set property ‘xxxx‘ of undefinedSessionUndefined
- Cannot set property 'innerHTML' of nullHTMLNull
- js提示Cannot read property ‘replace‘ of undefinedJSUndefined
- Cannot set property ‘type‘ of null(vue)NullVue
- echarts:Uncaught TypeError: Cannot read property '0' of undefinedEchartsErrorUndefined
- 前端報錯:cannot read property length of undefined前端Undefined
- 開發中遇到的bug-Cannot set property ‘__VUE_DEVTOOLS_UID__‘ of nullVuedevUINull
- vue 踩坑記錄 cannot read property xxx of undefinedVueUndefined
- 執行專案報錯Cannot read property 'styles' of undefinedUndefined
- el-tree 報錯 TypeError: Cannot read property ‘setCheckedKeys‘ of undefined“ErrorUndefined
- [譯] 避免那些可惡的 "cannot read property of undefined" 錯誤Undefined
- Cannot set property ‘dataIndex‘ of undefined 大資料關係圖報錯,賦予的資料有重複,去重AIIndexUndefined大資料
- vue-router.esm.js?fe87:2210 TypeError: Cannot read property ‘$createElement‘ of undefinedVueJSErrorUndefined
- [Vue warn]: Error in render: "TypeError: Cannot read property 'matched' of undefined" found in <App> at src/App.vueVueErrorUndefinedAPP
- vue 中引用echarts 初始化init undefind問題(Cannot read property ‘init‘ of undefined)VueEchartsUndefined
- Need to set ‘serverTimezone‘ propertyServer
- AndroidStudio之自定義輸出包名報錯 Cannot set the value of read-only property 'outputFile' forAndroid
- (排坑) Cannot create property 'key' on boolean 'true'Boolean
- Undefined property: stdClass::$column_name 怎麼解決?Undefined
- cannot read prpperty ‘start‘ of undefined(問題記錄)Undefined
- vue+echarts報錯Cannot read property ‘init‘ of underfinedVueEcharts
- Angularjs——初識AngularJSAngularJS
- 開發中遇到的bug-Property or method “xxxx“ is not defined on the instance but referenced during render.
- Server returns invalid timezone. Need to set ‘serverTimezone‘ property. Idea連線mysql報錯問題ServerIdeaMySql
- mkfs.ext4: undefined symbol: ext2fs_numeric_progress_ops、set_com_err_gettextUndefinedSymbol
- Java更新資料庫報錯:Data truncation: Cannot create a JSON value from a string with CHARACTER SETJava資料庫JSON
- AngularJS(二、如何用AngularJS建立前端程式碼框架)AngularJS前端框架
- UE floating pawn movement Bug Set location 導致速度異常發射
- AngularJS整理(1.0.0)AngularJS
- 初識AngularJSAngularJS
- AngularJS之FilterAngularJSFilter
- share undefinedUndefined
- [composer包]free-pic 免費圖床圖床
- @property @synthesize @dynamic
- Property屬性
- Request: credentials property
- AngularJS 4(三)【指令】AngularJS