How to make array data from api values with for loop and typescriptHow does data binding work in AngularJS?How can I post data as form data instead of a request payload?How do I set the value property in AngularJS' ng-options?How do you explicitly set a new property on `window` in TypeScript?How do I bind to list of checkbox values with AngularJS?How to iterate over the keys and values with ng-repeat in AngularJS?How do I remove an array item in TypeScript?$success call back function from AngularJSHow to implement class constants in typescript?Angular Api get request issue
What are the penalties for overstaying in USA?
How precise do models need to be for 3d printing?
What happens when your group is victim of a surprise attack but you can't be surprised?
How to / is it possible to straighten a bent seatstay/chainstay on a steel frame? At home or inexpensively by a professional
C-152 carb heat on before landing in hot weather?
Change the boot order with no option in UEFI settings
Impossible darts scores
Require advice on power conservation for backpacking trip
How risky is real estate?
Archery in modern conflicts
How to perform Login Authentication at the client-side?
Why do some professors with PhDs leave their professorships to teach high school?
How does a blind passenger not die, if driver becomes unconscious
Can I compare DFT calculations with different grids?
Can White Castle? #2
Cascading Repair Costs following Blown Head Gasket on a 2004 Subaru Outback
Changing the opacity of lines on a plot based on their value
Employer wants to use my work email account after I quit
Why are there so many 'vimrcs'?
Apply brace expansion in "reverse order"
Unusual mail headers, evidence of an attempted attack. Have I been pwned?
Can ADFS connect to other SSO services?
Why is there no havdallah when going from Yom Tov into Shabbat?
How to add multiple ip address in destination ip in acl rule
How to make array data from api values with for loop and typescript
How does data binding work in AngularJS?How can I post data as form data instead of a request payload?How do I set the value property in AngularJS' ng-options?How do you explicitly set a new property on `window` in TypeScript?How do I bind to list of checkbox values with AngularJS?How to iterate over the keys and values with ng-repeat in AngularJS?How do I remove an array item in TypeScript?$success call back function from AngularJSHow to implement class constants in typescript?Angular Api get request issue
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I want to put the values i get back from the api with the loop in to an array that i can use latter but i am drawing a blank on how to pass the values to the array from the loop.
i have tried to pass the value to an array outside the loop but failed.
export let apiController = app.controller("api", function ($scope, $http) {
//https://ergast.com/api/f1/2013/driverStandings.json
$scope.allDrivers = function () {
console.log("I've been pressed!");
$http.get("https://ergast.com/api/f1/2013/driverStandings.json").then(
function successCallback(response)
$scope.response = response;
console.log("response");
console.log(response);
console.log("response.data.MRData.StandingsTable.StandingsLists.0.DriverStandings");
console.log(response.data.MRData.StandingsTable.StandingsLists[0].DriverStandings);
let duzinaNiza = response.data.MRData.StandingsTable.StandingsLists[0].DriverStandings;
console.log(parseInt(duzinaNiza.length));
let duzinaNumber: number = parseInt(duzinaNiza.length);
console.log(duzinaNumber);
let nameVozaca; // inicializacija promenjivih
let prezimeVozaca;
let driverPosition;
let driverPoints;
let i = 0;
for (; i < duzinaNumber; i++) // for loop is ok just fix the number issue
nameVozaca = response.data.MRData.StandingsTable.StandingsLists[0].DriverStandings[i].Driver.givenName;
prezimeVozaca = response.data.MRData.StandingsTable.StandingsLists[0].DriverStandings[i].Driver.driverId;
driverPosition = (response.data.MRData.StandingsTable.StandingsLists[0].DriverStandings[i].position);
driverPoints = response.data.MRData.StandingsTable.StandingsLists[0].DriverStandings[i].points;
console.log( "position " + driverPosition + " ime Vozaca " + nameVozaca + " prezime Vozaca " + prezimeVozaca + " " + " Points " + driverPoints);
i just want to have the values that are returned by the for loop added to 4 seperate arrays for future use.
angularjs typescript
add a comment |
I want to put the values i get back from the api with the loop in to an array that i can use latter but i am drawing a blank on how to pass the values to the array from the loop.
i have tried to pass the value to an array outside the loop but failed.
export let apiController = app.controller("api", function ($scope, $http) {
//https://ergast.com/api/f1/2013/driverStandings.json
$scope.allDrivers = function () {
console.log("I've been pressed!");
$http.get("https://ergast.com/api/f1/2013/driverStandings.json").then(
function successCallback(response)
$scope.response = response;
console.log("response");
console.log(response);
console.log("response.data.MRData.StandingsTable.StandingsLists.0.DriverStandings");
console.log(response.data.MRData.StandingsTable.StandingsLists[0].DriverStandings);
let duzinaNiza = response.data.MRData.StandingsTable.StandingsLists[0].DriverStandings;
console.log(parseInt(duzinaNiza.length));
let duzinaNumber: number = parseInt(duzinaNiza.length);
console.log(duzinaNumber);
let nameVozaca; // inicializacija promenjivih
let prezimeVozaca;
let driverPosition;
let driverPoints;
let i = 0;
for (; i < duzinaNumber; i++) // for loop is ok just fix the number issue
nameVozaca = response.data.MRData.StandingsTable.StandingsLists[0].DriverStandings[i].Driver.givenName;
prezimeVozaca = response.data.MRData.StandingsTable.StandingsLists[0].DriverStandings[i].Driver.driverId;
driverPosition = (response.data.MRData.StandingsTable.StandingsLists[0].DriverStandings[i].position);
driverPoints = response.data.MRData.StandingsTable.StandingsLists[0].DriverStandings[i].points;
console.log( "position " + driverPosition + " ime Vozaca " + nameVozaca + " prezime Vozaca " + prezimeVozaca + " " + " Points " + driverPoints);
i just want to have the values that are returned by the for loop added to 4 seperate arrays for future use.
angularjs typescript
You want all above value in single array ? or you want 4 different array with above value ?
– CodeChanger
Mar 25 at 10:25
nameVozaca = response.data.MRData.StandingsTable.StandingsLists[0].DriverStandings[i].Driver.givenName; for example returns a list of names i want to put those names in an array so i can use it. same with the other values the loop returns.
– Marko Dunovic
Mar 25 at 10:26
add a comment |
I want to put the values i get back from the api with the loop in to an array that i can use latter but i am drawing a blank on how to pass the values to the array from the loop.
i have tried to pass the value to an array outside the loop but failed.
export let apiController = app.controller("api", function ($scope, $http) {
//https://ergast.com/api/f1/2013/driverStandings.json
$scope.allDrivers = function () {
console.log("I've been pressed!");
$http.get("https://ergast.com/api/f1/2013/driverStandings.json").then(
function successCallback(response)
$scope.response = response;
console.log("response");
console.log(response);
console.log("response.data.MRData.StandingsTable.StandingsLists.0.DriverStandings");
console.log(response.data.MRData.StandingsTable.StandingsLists[0].DriverStandings);
let duzinaNiza = response.data.MRData.StandingsTable.StandingsLists[0].DriverStandings;
console.log(parseInt(duzinaNiza.length));
let duzinaNumber: number = parseInt(duzinaNiza.length);
console.log(duzinaNumber);
let nameVozaca; // inicializacija promenjivih
let prezimeVozaca;
let driverPosition;
let driverPoints;
let i = 0;
for (; i < duzinaNumber; i++) // for loop is ok just fix the number issue
nameVozaca = response.data.MRData.StandingsTable.StandingsLists[0].DriverStandings[i].Driver.givenName;
prezimeVozaca = response.data.MRData.StandingsTable.StandingsLists[0].DriverStandings[i].Driver.driverId;
driverPosition = (response.data.MRData.StandingsTable.StandingsLists[0].DriverStandings[i].position);
driverPoints = response.data.MRData.StandingsTable.StandingsLists[0].DriverStandings[i].points;
console.log( "position " + driverPosition + " ime Vozaca " + nameVozaca + " prezime Vozaca " + prezimeVozaca + " " + " Points " + driverPoints);
i just want to have the values that are returned by the for loop added to 4 seperate arrays for future use.
angularjs typescript
I want to put the values i get back from the api with the loop in to an array that i can use latter but i am drawing a blank on how to pass the values to the array from the loop.
i have tried to pass the value to an array outside the loop but failed.
export let apiController = app.controller("api", function ($scope, $http) {
//https://ergast.com/api/f1/2013/driverStandings.json
$scope.allDrivers = function () {
console.log("I've been pressed!");
$http.get("https://ergast.com/api/f1/2013/driverStandings.json").then(
function successCallback(response)
$scope.response = response;
console.log("response");
console.log(response);
console.log("response.data.MRData.StandingsTable.StandingsLists.0.DriverStandings");
console.log(response.data.MRData.StandingsTable.StandingsLists[0].DriverStandings);
let duzinaNiza = response.data.MRData.StandingsTable.StandingsLists[0].DriverStandings;
console.log(parseInt(duzinaNiza.length));
let duzinaNumber: number = parseInt(duzinaNiza.length);
console.log(duzinaNumber);
let nameVozaca; // inicializacija promenjivih
let prezimeVozaca;
let driverPosition;
let driverPoints;
let i = 0;
for (; i < duzinaNumber; i++) // for loop is ok just fix the number issue
nameVozaca = response.data.MRData.StandingsTable.StandingsLists[0].DriverStandings[i].Driver.givenName;
prezimeVozaca = response.data.MRData.StandingsTable.StandingsLists[0].DriverStandings[i].Driver.driverId;
driverPosition = (response.data.MRData.StandingsTable.StandingsLists[0].DriverStandings[i].position);
driverPoints = response.data.MRData.StandingsTable.StandingsLists[0].DriverStandings[i].points;
console.log( "position " + driverPosition + " ime Vozaca " + nameVozaca + " prezime Vozaca " + prezimeVozaca + " " + " Points " + driverPoints);
i just want to have the values that are returned by the for loop added to 4 seperate arrays for future use.
angularjs typescript
angularjs typescript
edited Apr 15 at 19:18
Shanika Harshani
82 silver badges11 bronze badges
82 silver badges11 bronze badges
asked Mar 25 at 10:17
Marko DunovicMarko Dunovic
195 bronze badges
195 bronze badges
You want all above value in single array ? or you want 4 different array with above value ?
– CodeChanger
Mar 25 at 10:25
nameVozaca = response.data.MRData.StandingsTable.StandingsLists[0].DriverStandings[i].Driver.givenName; for example returns a list of names i want to put those names in an array so i can use it. same with the other values the loop returns.
– Marko Dunovic
Mar 25 at 10:26
add a comment |
You want all above value in single array ? or you want 4 different array with above value ?
– CodeChanger
Mar 25 at 10:25
nameVozaca = response.data.MRData.StandingsTable.StandingsLists[0].DriverStandings[i].Driver.givenName; for example returns a list of names i want to put those names in an array so i can use it. same with the other values the loop returns.
– Marko Dunovic
Mar 25 at 10:26
You want all above value in single array ? or you want 4 different array with above value ?
– CodeChanger
Mar 25 at 10:25
You want all above value in single array ? or you want 4 different array with above value ?
– CodeChanger
Mar 25 at 10:25
nameVozaca = response.data.MRData.StandingsTable.StandingsLists[0].DriverStandings[i].Driver.givenName; for example returns a list of names i want to put those names in an array so i can use it. same with the other values the loop returns.
– Marko Dunovic
Mar 25 at 10:26
nameVozaca = response.data.MRData.StandingsTable.StandingsLists[0].DriverStandings[i].Driver.givenName; for example returns a list of names i want to put those names in an array so i can use it. same with the other values the loop returns.
– Marko Dunovic
Mar 25 at 10:26
add a comment |
1 Answer
1
active
oldest
votes
I found an answer rather simple:
let imenaVozaca = []; outside loop for the data i want to push to array.
imenaVozaca.push(nameVozaca); in loop for the data that is being pushed
console.log("this is the array "); just a check :)
console.log(imenaVozaca);
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55335519%2fhow-to-make-array-data-from-api-values-with-for-loop-and-typescript%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I found an answer rather simple:
let imenaVozaca = []; outside loop for the data i want to push to array.
imenaVozaca.push(nameVozaca); in loop for the data that is being pushed
console.log("this is the array "); just a check :)
console.log(imenaVozaca);
add a comment |
I found an answer rather simple:
let imenaVozaca = []; outside loop for the data i want to push to array.
imenaVozaca.push(nameVozaca); in loop for the data that is being pushed
console.log("this is the array "); just a check :)
console.log(imenaVozaca);
add a comment |
I found an answer rather simple:
let imenaVozaca = []; outside loop for the data i want to push to array.
imenaVozaca.push(nameVozaca); in loop for the data that is being pushed
console.log("this is the array "); just a check :)
console.log(imenaVozaca);
I found an answer rather simple:
let imenaVozaca = []; outside loop for the data i want to push to array.
imenaVozaca.push(nameVozaca); in loop for the data that is being pushed
console.log("this is the array "); just a check :)
console.log(imenaVozaca);
edited Mar 25 at 11:01
CodeChanger
4,1261 gold badge19 silver badges47 bronze badges
4,1261 gold badge19 silver badges47 bronze badges
answered Mar 25 at 10:33
Marko DunovicMarko Dunovic
195 bronze badges
195 bronze badges
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55335519%2fhow-to-make-array-data-from-api-values-with-for-loop-and-typescript%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You want all above value in single array ? or you want 4 different array with above value ?
– CodeChanger
Mar 25 at 10:25
nameVozaca = response.data.MRData.StandingsTable.StandingsLists[0].DriverStandings[i].Driver.givenName; for example returns a list of names i want to put those names in an array so i can use it. same with the other values the loop returns.
– Marko Dunovic
Mar 25 at 10:26