Reputation: 43
My code is below from an Angular js file,
ctrl.issuesGridConfig = {
modelSetName: 'issues',
serializerChildName: 'issues', //will be prepended with "__" before fields for validation
actions: {
addRow: {
active: function(row) {return !ctrl.readOnly;},
callback: addIssueRow,
},
editRow: {
active: function(issue){ return issue.provider_issue_code;} ? true : false,
label: "View test" : "Edit",
callback: function(issue){
$location.path('/issue/' + issue.provider_issue_code);
}
},
deleteRow: {
active: function(row) {return !ctrl.readOnly;},
callback: function(row){
_.pull(ctrl.activity.issues, row);
}
}
},
My problem is- under the Editrow I am running the function(issue). it is working fine in callback:, but for active: it does not work. I get value of issue.provider_issue_code under callback:, but not under active:. I want to make active = true only if issue.provider_issue_code has some value. Please let me know whats going wrong here.
Upvotes: 0
Views: 56
Reputation: 7326
Wrong code there, active is always true because of your wrong typo, in your code you assign active with a ternary operator: active = condition ? true : false; (the function is the condition there)
active: function(issue){ return issue.provider_issue_code;} ? true : false,
should be
active: function(issue){ return issue.provider_issue_code ? true : false;} ,
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_Operator
Upvotes: 1