@byeongsoek wrote:
This is silly question, but I am wandering.
I have blank array and I want to push a value into the array.
my code: cloud.ts
this.connected_cloud = [ { name:'connected_csp[0]', value:this.csp.connectedCspList[0] } ]; this.connectable_cloud = [ { name:'connected_csp[0]', value: this.csp.connectableCspList[0] }, { name:'connected_csp[1]', value: this.csp.connectableCspList[1] }, { name:'connected_csp[2]', value: this.csp.connectableCspList[2] }, { name:'connected_csp[3]', value: this.csp.connectableCspList[3] } ]; openCloud(i) { if (i == 0) { } else if (i == 1) { this.dropbox.login().then((success) => { this.navCtrl.setRoot(CloudPage); alert('dropbox connected'); this.csp.pushConnectedCsp('Dropbox'); this.csp.popConnectedCsp(i); }, (err) => { alert(err); }); } else if (i == 2) { } else if (i == 3) { } else if (i == 4) { } else if (i == 5) { } }
csp.ts (provider)
public connectableCspList:Array<string>=['Google Drive', 'Dropbox', 'pCloud', 'MediaFire']; public connectedCspList:Array<string>=[null]; pushConnectedCsp(csp){ this.connectedCspList.push(csp); } popConnectableCsp(i){ this.connectableCsp.pop(); // I do not know this part also' }
My expectation: When I choose dropbox in a list, dropbox.login() method executed (<-this part has no problem) and then ‘Dropbox’ is added in the ‘Connected’ list and removed in the ‘Connectable’ list.
I searched some topics about push and pop method but I couldn’t apply it to my code.
I see this topic: [How to push value into an array] but I couldn’t also.
Considering I’m new at JavaScript and Ionic framework, please give me an advice. Thanks
Posts: 1
Participants: 1