Search Posts

Category: arrays

How to replace multiple keywords in a string with a component

To start off, I’m primarily an AngularJS developer and recently switched to React, and I decided to convert an angular webapp I had previously developed to a react app. Im having a bit of an issue with a component ExpressiveText that searches through a string for a match to a property on a list objects and inserts a component TriggerModal in its place that when clicked triggers a modal with more detailed information. So the […]

How to assign keys to existing array?

I have data from a backend that I want to push to fields but I want to assign values to objectKey from the data object. Like [{objectkey:”Normal”},{objectKey:”Network Element”}] main.js this.fields = [{ name: ‘Ticket Number’, objectKey: ‘ticketNum’, click: (row) => {this.rowData(row);} },{ name:’Ticket Opened’, objectKey:’ticketOpened’, click: (row) => {this.rowData(row);} }] data.forEach(function(item){ item[i] = this.fields[objectKey]; } data from server const data = [{ assetPriority:”Normal”, assetType:”Network Element”, avgChargeAmt:”1200.00″ }]; Source: AngularJS

AngularJS injecting duplicate $$hashkey and causing error

I don’t know why suddenly this began but for the life of me I can’t figure it out. This code has been working and now suddenly I am getting this. In my $q.all() statement I am processing all the returned results and assigning them to a new array. After the processing is done I print the new array to console and see a duplicate entry in my results. var newResults = [] ; return $q.all([promise1(),promise2(),promise3(),promise4()]) […]

populate a list or array in different dropdowns without showing the values populated in the frontend

I have a array with values 1,2,3,4. I can create multiple dropdown using a add function. For the first time let suppose the default value of the first dropdown is always one. We press add and populate the second dropdown the values which are 2,3,4, which should be displayed As soon as we select 2 as value of the second dropdown, the options in the first dropdown should stop showing 2 as a value option. […]

How to create an array from json ionic

Below is the data i get from the rest API { “memberdetails”:[ { “id”:46, “customername”:”Zack”, “phoneno”:”1323223232″, “nickname”:”Zack”, “regdate”:”2017-12-27 18:38:36.185829″, “groupname”:”Test group”, “regid”:36, “groupdesc”:”Test Test test”, “groupicon”:”new”, “tamount”:”3100″ }, { “id”:46, “customername”:”Carol”, “phoneno”:”254721493487″, “nickname”:”Caro”, “regdate”:”2017-12-28 23:47:22.317687″, “groupname”:”Test”, “regid”:36, “groupdesc”:”Test Test Test”, “groupicon”:”new”, “tamount”:”130″ } ] } From the above data i want to populate 2 arrays as i want to plot a graph in the below format. The lineChartData array should pick the tamount and the […]

Remove first object from json on checkbox click – AngularJs + NodeJs

This is my JSON object: [ { field1: ‘gsm’, field2: ‘firstname’, field3: ‘lastname’, field4: ‘street’, field5: ‘city’, field6: ‘region’, field7: ‘postcode’, field8: ‘dob’, field9: ’email’, field10: ‘company’, field11: ‘url’, field12: ‘country’, field13: ‘data1’, field14: ‘data2’, field15: ‘data3’ }, { field1: ‘123456789’, field2: ‘Mohamed’, field3: ‘Sameer’, field4: ‘Salai’, field5: ‘Salai’, field6: ‘Asia’, field7: ‘111111’, field8: ’10-10-10′, field9: ‘[email protected]’, field10: ‘ifelse’, field11: ‘ifelse’, field12: ‘India’, field13: ‘test’, field14: ‘test’, field15: ‘test’ }, { field1: ‘123456789’, field2: ‘Hameed’, […]

splitting comma-separated object in array to use in ng-repeat

I am working in ServiceNow and have an object array where one of the objects is a comma-separated list. I want to split object by ‘,’ and then use it in an ng-repeat to compile a bulleted list, but can’t seem to get it to show up correctly. My GlideRecord query looks like this: var userTasks = new GlideRecord(task_table); userTasks.addQuery(‘assigned_to’, user_sysID); userTasks.query(); while( { created_by_bundle = userTasks.getValue(‘created_by_bundle’); var bundle = userTasks.created_by_bundle.getRefRecord(); data.list.push({ number: userTasks.getValue(‘number’), parent: […]

How to display ng-repeat data with certain conditions – AngularJS

This is my json object response: { “draftType”: “manualinput”, “senderdata”: “123456789”, “senderName”: “ifelse”, “message”: “Hi”, “draftName”: “Testing” } I am displaying this in UI using ng-repeat: controllers.js: $http({ method: ‘GET’, url: ‘/api/getdraft’ }).then(function (response) { $scope.drafts =; }, function (response) { console.log(response); }); my code: tr(ng-repeat=’draft in drafts’) td {{draft.draftName}} td {{draft.senderName}} td {{draft.message}} But i need some condition, if my draftType object key have string called “manualinput” i want to display datas, sometimes […]

Access data from one controller to another controller- AngularJS

addressbookController : $http({ method: ‘GET’, url: ‘/api/getnewgroup’ }) .then(function (response) { $scope.draft.groups =; $scope.groups =; // updated }, function (response) { console.log(response); }); In this above controller, i am getting json response in $scope.draft.groups, I have this draft object in another controller called profsmsController. profsmsController : $scope.draft = { draftType: ”, scheduledTime: ”, senderdata: ”, draftData: { contacts: ” }, groups: { select: false }, senderName: ”, message: ”, draftName: ”, createdOn: ”, […]

Next Page »