Issue
I have the following code
var secClassesToCreate = _this.$filter('filter')(_this.selectedSecurityClasses, {operation: 'CREATE'});
var selectedSecClasses = _this.$filter('filter')(_this.selectedSecurityClasses,
function(item) {
return item.operation === undefined
}
);
for (var i = 0; i < businessDataRule.businessRuleSecurities.length; i++) {
if (_this.$filter('filter')(selectedSecClasses, {id: businessDataRule.businessRuleSecurities[i].securityClassId}).length === 0) {
businessDataRule.businessRuleSecurities[i].operation = 'DELETE';
}
}
I need to migrate to angular newer versions so angular 10.What is the code doing here ? How can be migrated to angular newer version I am not familiar with angular.js that is why I am asking.
Solution
Here is missing a lot of explanation but in general in typescript this should look something like this:
let secClassesToCreate = _this.selectedSecurityClasses.filter((secClass)=>{return secClass.operation=='CREATE'});
let selectedSecClasses = _this.selectedSecurityClasses.filter((secClass)=>{return secClass.operation===undefined}),
businessDataRule.businessRuleSecurities.forEach((rule) => {
if (selectedSecClasses.filter((secClass)=>{return secClass.id == rule.securityClassId;}).length ===0){
rule.operation = 'DELETE';
}
});
Answered By - AvgustinTomsic
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.