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 set property 'innerHTML' of nullHTMLNull
- Cannot read property ‘aDataSort‘ of undefinedUndefined
- Cannot set property ‘type‘ of null(vue)NullVue
- js提示Cannot read property ‘replace‘ of undefinedJSUndefined
- echarts:Uncaught TypeError: Cannot read property '0' of undefinedEchartsErrorUndefined
- 前端報錯:cannot read property length of undefined前端Undefined
- 使用req.session.xxx時出現 Cannot set property ‘xxxx‘ of undefinedSessionUndefined
- 開發中遇到的bug-Cannot set property ‘__VUE_DEVTOOLS_UID__‘ of nullVuedevUINull
- 執行專案報錯Cannot read property 'styles' of undefinedUndefined
- Appium dmg 安裝:[TypeError: Cannot read property 'replace' of undefined]APPErrorUndefined
- [譯] 避免那些可惡的 "cannot read property of undefined" 錯誤Undefined
- vue 踩坑記錄 cannot read property xxx of undefinedVueUndefined
- Cannot set property ‘dataIndex‘ of undefined 大資料關係圖報錯,賦予的資料有重複,去重AIIndexUndefined大資料
- el-tree 報錯 TypeError: Cannot read property ‘setCheckedKeys‘ of undefined“ErrorUndefined
- vue 中引用echarts 初始化init undefind問題(Cannot read property ‘init‘ of undefined)VueEchartsUndefined
- [Vue warn]: Error in render: "TypeError: Cannot read property 'matched' of undefined" found in <App> at src/App.vueVueErrorUndefinedAPP
- vue-router.esm.js?fe87:2210 TypeError: Cannot read property ‘$createElement‘ of undefinedVueJSErrorUndefined
- Need to set ‘serverTimezone‘ propertyServer
- (排坑) Cannot create property 'key' on boolean 'true'Boolean
- Undefined property: stdClass::$column_name 怎麼解決?Undefined
- AndroidStudio之自定義輸出包名報錯 Cannot set the value of read-only property 'outputFile' forAndroid
- cannot read prpperty ‘start‘ of undefined(問題記錄)Undefined
- vue+echarts報錯Cannot read property ‘init‘ of underfinedVueEcharts
- cannot set user id: Resource temporarily unavailableAI
- How to: Use Resources to Set Property Values in Web Server ControlsWebServer
- su cannot set user id Resource temporarily unavailable故障解決AI
- 11.2.0.2 Patch Set - List of Bug Fixes by Problem Type
- su - oracle報錯su: cannot set user id: Resource temporarily unavailableOracleAI
- ORA-00265: instance recovery required, cannot set ARCHIVELOGUIHive
- (問題解決)Cannot set LC_CTYPE to default locale: No such file or directory
- 452 Error writing file: A file cannot be larger than the value set by ulimit.ErrorMIT
- Bug 4872999 - RAC instance cannot get global enqueueENQ
- 解決-Dmaven.multiModuleProjectDirectory system property is not set. Check $M2_HOME environment...MavenProject
- JPDA and Set up Tomcat for Remote DebuggingTomcatREM
- V8 的 typeof null 返回 "undefined" 的 bug 是怎麼回事NullUndefined
- ORA-00265: instance recovery required, cannot set ARCHIVELOG modeUIHive
- DEBUG : Eclipse Debug 時出現 Cannot connect to VM select failed錯誤EclipseAI
- ORA-00824:cannot set sga_target due to existing internal setting --SOLUTION