Reputation: 1024
Ok this probably is stupid question but I've been sitting here trying to fix this issue. I have a select list and when it changes to a specific value i'm trying to set a property to empty string and disable some other fields. Problem is I keep getting the 'TypeError: Cannot set property 'msrp' of null error. I've been looking at this for a while now. Here is the code :
var msrp;
vm.changeDealType = function changeDealType(myScenario, typeId) {
scenario.isCashDealType = false;
msrp = '';
if( typeId.value !== null && typeId.value === "Cash"){
myScenario.isCashDealType = true;
myScenario.original.msrp = msrp;
}
};
Upvotes: 0
Views: 75
Reputation: 4097
I've tried your codes, remember you need to send the proper input as required for your function for example:
var myScenario = {};
myScenario.original = {};
var typeId = {};
changeDealType(myScenario, typeId);
You may try with this working code without any errors:
var msrp;
function changeDealType(myScenario, typeId) {
myScenario.isCashDealType = false;
msrp = '';
if (typeId.value !== null && typeId.value === "Cash") {
myScenario.isCashDealType = true;
myScenario.original.msrp = msrp;
}
};
var myScenario = {};
myScenario.original = {};
var typeId = {};
changeDealType(myScenario, typeId);
Upvotes: 1