TypeError: Cannot read property '0' of undefined from the Array using AngularJS










0














I am trying to create a webpage where when a user logs in from the login page, my page that is the 'user management' page should display users belonging to the login user's company.



For eg: When a user belonging to company APPLE logs in, this webpage should only display users belonging to APPLE.



In the code, "currentUser" is the login user I get from the login page via localStorage getItem. "allUsers" array is the list of all users from different companies. Empty array "user" should display only display Current user's company's-users from the list of allUsers.



For that I have used FOR LOOP seen at the end of the JS file. I'm getting a error that the property 'company' is undefined. Looking for someone to help me. Thanks in advance.



 var myApp = angular.module("myApp", );

myApp.controller("myController", function ($scope)
console.log("in controller...");
$scope.newUser = ;
$scope.info = "";

if ($scope.users = JSON.parse(localStorage.getItem("users")) !== null)

$scope.users = JSON.parse(localStorage.getItem("users"));


if (localStorage.getItem("currentUser") !== null)

var currentUser = JSON.parse(localStorage.getItem("currentUser"));
console.log("Received");

else
console.log("Not received");


if (localStorage.getItem("allUsers") === null)
$scope.allUsers = [
email: "John@yahoo.com", password:"John123", firstName: "John", lastName: "Doe", contact: "281-283-2480", role: "Supplier-Admin", company: "Apple" ,
email: "Rick@yahoo.com", password: "Rick123", firstName: "Rick", lastName: "Fraiser", contact: "987-283-2489", role: "Supplier-User", company: "Apple" ,
email: "Sam@yahoo.com", password: "Sam123", firstName: "Sam", lastName: "Tarly", contact: "456-786-2480", role: "BuyerAdmin", company: "Samsung"
];
localStorage.setItem("allUsers", JSON.stringify($scope.allUsers));
// localStorage.setItem("users", JSON.stringify($scope.users));
else
$scope.allUsers = JSON.parse(localStorage.getItem("allUsers"));


//filter allUsers based on currentUser's role
for (var i = 0; $scope.allUsers.length; i++)
$scope.users = [];
if ($scope.allUsers[i].company === currentUser[0].company)
$scope.users.push($scope.allUser[i]);

localStorage.setItem("users", JSON.stringify($scope.users));

);









share|improve this question























  • Your currentUser may be undefined. Check your condition in the retrieving of your currentUser from the localstorage.
    – Sw0ut
    Nov 12 '18 at 15:38










  • The currentUser array does show in the localStorage in the browser developer tools. And I also get the console message "Received" under the if (localStorage.getItem("currentUser") != null) statement.
    – Vaibhav Shankar
    Nov 12 '18 at 16:03










  • Maybe, but you should add a condition. And I don't see a declaration of your i variable. You should clean your localstorage, because residual things of what you did before may stay in your variables.
    – Sw0ut
    Nov 12 '18 at 16:07










  • @Sw0ut I did clear localStorage, still no good. I don't understand what do you mean by- "And I don't see a declaration of your i variable". I can say that the code certainly gets the currentUser data because it shows the message "Received". If i clear the CurrentUser data and run again, I get "Not received".
    – Vaibhav Shankar
    Nov 12 '18 at 16:14















0














I am trying to create a webpage where when a user logs in from the login page, my page that is the 'user management' page should display users belonging to the login user's company.



For eg: When a user belonging to company APPLE logs in, this webpage should only display users belonging to APPLE.



In the code, "currentUser" is the login user I get from the login page via localStorage getItem. "allUsers" array is the list of all users from different companies. Empty array "user" should display only display Current user's company's-users from the list of allUsers.



For that I have used FOR LOOP seen at the end of the JS file. I'm getting a error that the property 'company' is undefined. Looking for someone to help me. Thanks in advance.



 var myApp = angular.module("myApp", );

myApp.controller("myController", function ($scope)
console.log("in controller...");
$scope.newUser = ;
$scope.info = "";

if ($scope.users = JSON.parse(localStorage.getItem("users")) !== null)

$scope.users = JSON.parse(localStorage.getItem("users"));


if (localStorage.getItem("currentUser") !== null)

var currentUser = JSON.parse(localStorage.getItem("currentUser"));
console.log("Received");

else
console.log("Not received");


if (localStorage.getItem("allUsers") === null)
$scope.allUsers = [
email: "John@yahoo.com", password:"John123", firstName: "John", lastName: "Doe", contact: "281-283-2480", role: "Supplier-Admin", company: "Apple" ,
email: "Rick@yahoo.com", password: "Rick123", firstName: "Rick", lastName: "Fraiser", contact: "987-283-2489", role: "Supplier-User", company: "Apple" ,
email: "Sam@yahoo.com", password: "Sam123", firstName: "Sam", lastName: "Tarly", contact: "456-786-2480", role: "BuyerAdmin", company: "Samsung"
];
localStorage.setItem("allUsers", JSON.stringify($scope.allUsers));
// localStorage.setItem("users", JSON.stringify($scope.users));
else
$scope.allUsers = JSON.parse(localStorage.getItem("allUsers"));


//filter allUsers based on currentUser's role
for (var i = 0; $scope.allUsers.length; i++)
$scope.users = [];
if ($scope.allUsers[i].company === currentUser[0].company)
$scope.users.push($scope.allUser[i]);

localStorage.setItem("users", JSON.stringify($scope.users));

);









share|improve this question























  • Your currentUser may be undefined. Check your condition in the retrieving of your currentUser from the localstorage.
    – Sw0ut
    Nov 12 '18 at 15:38










  • The currentUser array does show in the localStorage in the browser developer tools. And I also get the console message "Received" under the if (localStorage.getItem("currentUser") != null) statement.
    – Vaibhav Shankar
    Nov 12 '18 at 16:03










  • Maybe, but you should add a condition. And I don't see a declaration of your i variable. You should clean your localstorage, because residual things of what you did before may stay in your variables.
    – Sw0ut
    Nov 12 '18 at 16:07










  • @Sw0ut I did clear localStorage, still no good. I don't understand what do you mean by- "And I don't see a declaration of your i variable". I can say that the code certainly gets the currentUser data because it shows the message "Received". If i clear the CurrentUser data and run again, I get "Not received".
    – Vaibhav Shankar
    Nov 12 '18 at 16:14













0












0








0







I am trying to create a webpage where when a user logs in from the login page, my page that is the 'user management' page should display users belonging to the login user's company.



For eg: When a user belonging to company APPLE logs in, this webpage should only display users belonging to APPLE.



In the code, "currentUser" is the login user I get from the login page via localStorage getItem. "allUsers" array is the list of all users from different companies. Empty array "user" should display only display Current user's company's-users from the list of allUsers.



For that I have used FOR LOOP seen at the end of the JS file. I'm getting a error that the property 'company' is undefined. Looking for someone to help me. Thanks in advance.



 var myApp = angular.module("myApp", );

myApp.controller("myController", function ($scope)
console.log("in controller...");
$scope.newUser = ;
$scope.info = "";

if ($scope.users = JSON.parse(localStorage.getItem("users")) !== null)

$scope.users = JSON.parse(localStorage.getItem("users"));


if (localStorage.getItem("currentUser") !== null)

var currentUser = JSON.parse(localStorage.getItem("currentUser"));
console.log("Received");

else
console.log("Not received");


if (localStorage.getItem("allUsers") === null)
$scope.allUsers = [
email: "John@yahoo.com", password:"John123", firstName: "John", lastName: "Doe", contact: "281-283-2480", role: "Supplier-Admin", company: "Apple" ,
email: "Rick@yahoo.com", password: "Rick123", firstName: "Rick", lastName: "Fraiser", contact: "987-283-2489", role: "Supplier-User", company: "Apple" ,
email: "Sam@yahoo.com", password: "Sam123", firstName: "Sam", lastName: "Tarly", contact: "456-786-2480", role: "BuyerAdmin", company: "Samsung"
];
localStorage.setItem("allUsers", JSON.stringify($scope.allUsers));
// localStorage.setItem("users", JSON.stringify($scope.users));
else
$scope.allUsers = JSON.parse(localStorage.getItem("allUsers"));


//filter allUsers based on currentUser's role
for (var i = 0; $scope.allUsers.length; i++)
$scope.users = [];
if ($scope.allUsers[i].company === currentUser[0].company)
$scope.users.push($scope.allUser[i]);

localStorage.setItem("users", JSON.stringify($scope.users));

);









share|improve this question















I am trying to create a webpage where when a user logs in from the login page, my page that is the 'user management' page should display users belonging to the login user's company.



For eg: When a user belonging to company APPLE logs in, this webpage should only display users belonging to APPLE.



In the code, "currentUser" is the login user I get from the login page via localStorage getItem. "allUsers" array is the list of all users from different companies. Empty array "user" should display only display Current user's company's-users from the list of allUsers.



For that I have used FOR LOOP seen at the end of the JS file. I'm getting a error that the property 'company' is undefined. Looking for someone to help me. Thanks in advance.



 var myApp = angular.module("myApp", );

myApp.controller("myController", function ($scope)
console.log("in controller...");
$scope.newUser = ;
$scope.info = "";

if ($scope.users = JSON.parse(localStorage.getItem("users")) !== null)

$scope.users = JSON.parse(localStorage.getItem("users"));


if (localStorage.getItem("currentUser") !== null)

var currentUser = JSON.parse(localStorage.getItem("currentUser"));
console.log("Received");

else
console.log("Not received");


if (localStorage.getItem("allUsers") === null)
$scope.allUsers = [
email: "John@yahoo.com", password:"John123", firstName: "John", lastName: "Doe", contact: "281-283-2480", role: "Supplier-Admin", company: "Apple" ,
email: "Rick@yahoo.com", password: "Rick123", firstName: "Rick", lastName: "Fraiser", contact: "987-283-2489", role: "Supplier-User", company: "Apple" ,
email: "Sam@yahoo.com", password: "Sam123", firstName: "Sam", lastName: "Tarly", contact: "456-786-2480", role: "BuyerAdmin", company: "Samsung"
];
localStorage.setItem("allUsers", JSON.stringify($scope.allUsers));
// localStorage.setItem("users", JSON.stringify($scope.users));
else
$scope.allUsers = JSON.parse(localStorage.getItem("allUsers"));


//filter allUsers based on currentUser's role
for (var i = 0; $scope.allUsers.length; i++)
$scope.users = [];
if ($scope.allUsers[i].company === currentUser[0].company)
$scope.users.push($scope.allUser[i]);

localStorage.setItem("users", JSON.stringify($scope.users));

);






javascript arrays angularjs






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 12 '18 at 16:54

























asked Nov 12 '18 at 15:34









Vaibhav Shankar

187




187











  • Your currentUser may be undefined. Check your condition in the retrieving of your currentUser from the localstorage.
    – Sw0ut
    Nov 12 '18 at 15:38










  • The currentUser array does show in the localStorage in the browser developer tools. And I also get the console message "Received" under the if (localStorage.getItem("currentUser") != null) statement.
    – Vaibhav Shankar
    Nov 12 '18 at 16:03










  • Maybe, but you should add a condition. And I don't see a declaration of your i variable. You should clean your localstorage, because residual things of what you did before may stay in your variables.
    – Sw0ut
    Nov 12 '18 at 16:07










  • @Sw0ut I did clear localStorage, still no good. I don't understand what do you mean by- "And I don't see a declaration of your i variable". I can say that the code certainly gets the currentUser data because it shows the message "Received". If i clear the CurrentUser data and run again, I get "Not received".
    – Vaibhav Shankar
    Nov 12 '18 at 16:14
















  • Your currentUser may be undefined. Check your condition in the retrieving of your currentUser from the localstorage.
    – Sw0ut
    Nov 12 '18 at 15:38










  • The currentUser array does show in the localStorage in the browser developer tools. And I also get the console message "Received" under the if (localStorage.getItem("currentUser") != null) statement.
    – Vaibhav Shankar
    Nov 12 '18 at 16:03










  • Maybe, but you should add a condition. And I don't see a declaration of your i variable. You should clean your localstorage, because residual things of what you did before may stay in your variables.
    – Sw0ut
    Nov 12 '18 at 16:07










  • @Sw0ut I did clear localStorage, still no good. I don't understand what do you mean by- "And I don't see a declaration of your i variable". I can say that the code certainly gets the currentUser data because it shows the message "Received". If i clear the CurrentUser data and run again, I get "Not received".
    – Vaibhav Shankar
    Nov 12 '18 at 16:14















Your currentUser may be undefined. Check your condition in the retrieving of your currentUser from the localstorage.
– Sw0ut
Nov 12 '18 at 15:38




Your currentUser may be undefined. Check your condition in the retrieving of your currentUser from the localstorage.
– Sw0ut
Nov 12 '18 at 15:38












The currentUser array does show in the localStorage in the browser developer tools. And I also get the console message "Received" under the if (localStorage.getItem("currentUser") != null) statement.
– Vaibhav Shankar
Nov 12 '18 at 16:03




The currentUser array does show in the localStorage in the browser developer tools. And I also get the console message "Received" under the if (localStorage.getItem("currentUser") != null) statement.
– Vaibhav Shankar
Nov 12 '18 at 16:03












Maybe, but you should add a condition. And I don't see a declaration of your i variable. You should clean your localstorage, because residual things of what you did before may stay in your variables.
– Sw0ut
Nov 12 '18 at 16:07




Maybe, but you should add a condition. And I don't see a declaration of your i variable. You should clean your localstorage, because residual things of what you did before may stay in your variables.
– Sw0ut
Nov 12 '18 at 16:07












@Sw0ut I did clear localStorage, still no good. I don't understand what do you mean by- "And I don't see a declaration of your i variable". I can say that the code certainly gets the currentUser data because it shows the message "Received". If i clear the CurrentUser data and run again, I get "Not received".
– Vaibhav Shankar
Nov 12 '18 at 16:14




@Sw0ut I did clear localStorage, still no good. I don't understand what do you mean by- "And I don't see a declaration of your i variable". I can say that the code certainly gets the currentUser data because it shows the message "Received". If i clear the CurrentUser data and run again, I get "Not received".
– Vaibhav Shankar
Nov 12 '18 at 16:14












1 Answer
1






active

oldest

votes


















0














localStorage.getItem() returns string representation of null, if the key has null value in localStorage so your null check might not be behaving like expected. I'd recommend to wrap getItem in a function that would check that.



function(itemName) 
const item = localStorage.getItem(itemName);
return item === 'null'
? null
: item;



Your problem is probably in the place where you set currentUser, maybe because of the same null check.



Also try declaring your i variable in for loop.



for(var i = 0; ...) ...


Edit



There seems to be an error in this line



if ($scope.allUsers[i].company === currentUser[0].company) 
$scope.users.push($scope.allUser[i]);



You're trying to push $scope.allUser[I] which is not defined, you've probably meant to write $scope.allUsers[I].






share|improve this answer






















  • Nope, still doesn't work. Getting the same error message 'Comapny' undefined.
    – Vaibhav Shankar
    Nov 12 '18 at 16:15










  • Could you change, console.log("Received");, to console.log("Received", currentUser); and show us the output? Did you check your spelling and case?
    – Simas.B
    Nov 12 '18 at 16:19










  • When i use this, console.log("Received", currentUser);, I get Array(0) with all the columns like Email, name, contact, company....along with their details. So that means the data does get received from the stroage right?
    – Vaibhav Shankar
    Nov 12 '18 at 16:29










  • So currentUser is an array then. You should then access it like one. currentUser[0].company
    – Simas.B
    Nov 12 '18 at 16:32










  • Oh you are right! But unfortunately, I am now getting '0' as undefined :(
    – Vaibhav Shankar
    Nov 12 '18 at 16:38










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
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53265378%2ftypeerror-cannot-read-property-0-of-undefined-from-the-array-using-angularjs%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









0














localStorage.getItem() returns string representation of null, if the key has null value in localStorage so your null check might not be behaving like expected. I'd recommend to wrap getItem in a function that would check that.



function(itemName) 
const item = localStorage.getItem(itemName);
return item === 'null'
? null
: item;



Your problem is probably in the place where you set currentUser, maybe because of the same null check.



Also try declaring your i variable in for loop.



for(var i = 0; ...) ...


Edit



There seems to be an error in this line



if ($scope.allUsers[i].company === currentUser[0].company) 
$scope.users.push($scope.allUser[i]);



You're trying to push $scope.allUser[I] which is not defined, you've probably meant to write $scope.allUsers[I].






share|improve this answer






















  • Nope, still doesn't work. Getting the same error message 'Comapny' undefined.
    – Vaibhav Shankar
    Nov 12 '18 at 16:15










  • Could you change, console.log("Received");, to console.log("Received", currentUser); and show us the output? Did you check your spelling and case?
    – Simas.B
    Nov 12 '18 at 16:19










  • When i use this, console.log("Received", currentUser);, I get Array(0) with all the columns like Email, name, contact, company....along with their details. So that means the data does get received from the stroage right?
    – Vaibhav Shankar
    Nov 12 '18 at 16:29










  • So currentUser is an array then. You should then access it like one. currentUser[0].company
    – Simas.B
    Nov 12 '18 at 16:32










  • Oh you are right! But unfortunately, I am now getting '0' as undefined :(
    – Vaibhav Shankar
    Nov 12 '18 at 16:38















0














localStorage.getItem() returns string representation of null, if the key has null value in localStorage so your null check might not be behaving like expected. I'd recommend to wrap getItem in a function that would check that.



function(itemName) 
const item = localStorage.getItem(itemName);
return item === 'null'
? null
: item;



Your problem is probably in the place where you set currentUser, maybe because of the same null check.



Also try declaring your i variable in for loop.



for(var i = 0; ...) ...


Edit



There seems to be an error in this line



if ($scope.allUsers[i].company === currentUser[0].company) 
$scope.users.push($scope.allUser[i]);



You're trying to push $scope.allUser[I] which is not defined, you've probably meant to write $scope.allUsers[I].






share|improve this answer






















  • Nope, still doesn't work. Getting the same error message 'Comapny' undefined.
    – Vaibhav Shankar
    Nov 12 '18 at 16:15










  • Could you change, console.log("Received");, to console.log("Received", currentUser); and show us the output? Did you check your spelling and case?
    – Simas.B
    Nov 12 '18 at 16:19










  • When i use this, console.log("Received", currentUser);, I get Array(0) with all the columns like Email, name, contact, company....along with their details. So that means the data does get received from the stroage right?
    – Vaibhav Shankar
    Nov 12 '18 at 16:29










  • So currentUser is an array then. You should then access it like one. currentUser[0].company
    – Simas.B
    Nov 12 '18 at 16:32










  • Oh you are right! But unfortunately, I am now getting '0' as undefined :(
    – Vaibhav Shankar
    Nov 12 '18 at 16:38













0












0








0






localStorage.getItem() returns string representation of null, if the key has null value in localStorage so your null check might not be behaving like expected. I'd recommend to wrap getItem in a function that would check that.



function(itemName) 
const item = localStorage.getItem(itemName);
return item === 'null'
? null
: item;



Your problem is probably in the place where you set currentUser, maybe because of the same null check.



Also try declaring your i variable in for loop.



for(var i = 0; ...) ...


Edit



There seems to be an error in this line



if ($scope.allUsers[i].company === currentUser[0].company) 
$scope.users.push($scope.allUser[i]);



You're trying to push $scope.allUser[I] which is not defined, you've probably meant to write $scope.allUsers[I].






share|improve this answer














localStorage.getItem() returns string representation of null, if the key has null value in localStorage so your null check might not be behaving like expected. I'd recommend to wrap getItem in a function that would check that.



function(itemName) 
const item = localStorage.getItem(itemName);
return item === 'null'
? null
: item;



Your problem is probably in the place where you set currentUser, maybe because of the same null check.



Also try declaring your i variable in for loop.



for(var i = 0; ...) ...


Edit



There seems to be an error in this line



if ($scope.allUsers[i].company === currentUser[0].company) 
$scope.users.push($scope.allUser[i]);



You're trying to push $scope.allUser[I] which is not defined, you've probably meant to write $scope.allUsers[I].







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 12 '18 at 17:07

























answered Nov 12 '18 at 16:07









Simas.B

18014




18014











  • Nope, still doesn't work. Getting the same error message 'Comapny' undefined.
    – Vaibhav Shankar
    Nov 12 '18 at 16:15










  • Could you change, console.log("Received");, to console.log("Received", currentUser); and show us the output? Did you check your spelling and case?
    – Simas.B
    Nov 12 '18 at 16:19










  • When i use this, console.log("Received", currentUser);, I get Array(0) with all the columns like Email, name, contact, company....along with their details. So that means the data does get received from the stroage right?
    – Vaibhav Shankar
    Nov 12 '18 at 16:29










  • So currentUser is an array then. You should then access it like one. currentUser[0].company
    – Simas.B
    Nov 12 '18 at 16:32










  • Oh you are right! But unfortunately, I am now getting '0' as undefined :(
    – Vaibhav Shankar
    Nov 12 '18 at 16:38
















  • Nope, still doesn't work. Getting the same error message 'Comapny' undefined.
    – Vaibhav Shankar
    Nov 12 '18 at 16:15










  • Could you change, console.log("Received");, to console.log("Received", currentUser); and show us the output? Did you check your spelling and case?
    – Simas.B
    Nov 12 '18 at 16:19










  • When i use this, console.log("Received", currentUser);, I get Array(0) with all the columns like Email, name, contact, company....along with their details. So that means the data does get received from the stroage right?
    – Vaibhav Shankar
    Nov 12 '18 at 16:29










  • So currentUser is an array then. You should then access it like one. currentUser[0].company
    – Simas.B
    Nov 12 '18 at 16:32










  • Oh you are right! But unfortunately, I am now getting '0' as undefined :(
    – Vaibhav Shankar
    Nov 12 '18 at 16:38















Nope, still doesn't work. Getting the same error message 'Comapny' undefined.
– Vaibhav Shankar
Nov 12 '18 at 16:15




Nope, still doesn't work. Getting the same error message 'Comapny' undefined.
– Vaibhav Shankar
Nov 12 '18 at 16:15












Could you change, console.log("Received");, to console.log("Received", currentUser); and show us the output? Did you check your spelling and case?
– Simas.B
Nov 12 '18 at 16:19




Could you change, console.log("Received");, to console.log("Received", currentUser); and show us the output? Did you check your spelling and case?
– Simas.B
Nov 12 '18 at 16:19












When i use this, console.log("Received", currentUser);, I get Array(0) with all the columns like Email, name, contact, company....along with their details. So that means the data does get received from the stroage right?
– Vaibhav Shankar
Nov 12 '18 at 16:29




When i use this, console.log("Received", currentUser);, I get Array(0) with all the columns like Email, name, contact, company....along with their details. So that means the data does get received from the stroage right?
– Vaibhav Shankar
Nov 12 '18 at 16:29












So currentUser is an array then. You should then access it like one. currentUser[0].company
– Simas.B
Nov 12 '18 at 16:32




So currentUser is an array then. You should then access it like one. currentUser[0].company
– Simas.B
Nov 12 '18 at 16:32












Oh you are right! But unfortunately, I am now getting '0' as undefined :(
– Vaibhav Shankar
Nov 12 '18 at 16:38




Oh you are right! But unfortunately, I am now getting '0' as undefined :(
– Vaibhav Shankar
Nov 12 '18 at 16:38

















draft saved

draft discarded
















































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.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • 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.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53265378%2ftypeerror-cannot-read-property-0-of-undefined-from-the-array-using-angularjs%23new-answer', 'question_page');

);

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







這個網誌中的熱門文章

Barbados

How to read a connectionString WITH PROVIDER in .NET Core?

Node.js Script on GitHub Pages or Amazon S3