im getting a little lost on why this is happening to me

if i do console.log(“Text = “+ previousMenu.get(i).name)
works shows me the text but when i try to pass on that value to another qml like my other model like so

Qt Code:
  1. subMenuModel.iName = previousMenu.get(i).name
  2.  
  3. i get the error
  4.  
  5. TypeError: Result of expression ‘previousMenu.get(i)’ [undefined] is not an object.
  6.  
  7. show you the code
  8.  
  9. function backButtonClicked() {
  10. for (var i = 0; i < previousMenu.count; ++i)
  11. {
  12. previousMenu.remove(i)
  13. subMenuModel.iName = previousMenu.get(i).name
  14.  
  15. // want an if i = null
  16. // do something here like change the state of the back button to disabled
  17. }
  18. }
  19. every item thats clicked gets appended to a listmodel then what i want to do is remove the LAST one in the list ie i = 1 remove 1 get 0
  20. if i is null dosomething
  21.  
  22. how can i achieve this ?
To copy to clipboard, switch view to plain text mode