As someone new to Angular, I am encountering an issue and would appreciate some help. Here is an array of objects I am working with:
signals = [{
'signalID': '123'
},{
'signalID': '233'
},{
'signalID': '333'
},{
'signalID': '433'
},{
'signalID': '533'
},{
'signalID': '633'
},{
'signalID': '733'
}]
Additionally, I have an object structured like this:
signalOrder = {
333:1,
433:2,
533:3
}
The goal is to add a 'orderNo' property to the signals array. If the 'signalID' matches a key in the signalOrder object, the 'orderNo' should be set accordingly, otherwise it should be null. The expected result is:
signals = [{
'signalID': '123',
'orderNo':null
},{
'signalID': '233',
'orderNo':null
},{
'signalID': '333',
'orderNo':1
},{
'signalID': '433',
'orderNo':2
},{
'signalID': '533',
'orderNo':3
},{
'signalID': '633',
'orderNo':null
},{
'signalID': '733',
'orderNo':null
}]
I believe this can be achieved using the JavaScript map function, though I am unsure of the exact implementation.