Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Empty array of objects predefined structure
Message
De
28/02/2017 14:59:12
 
 
Information générale
Forum:
Javascript
Catégorie:
Compatibilité Cross-browser
Divers
Thread ID:
01648635
Message ID:
01648638
Vues:
42
This message has been marked as a message which has helped to the initial question of the thread.
>Hi everybody,
>
>Is there a way to define an empty array that is going to hold objects of the predefined structure?
>
>Say, I want my object to be
>
>{fileName: "someName", key: "some unique string", type: "some type", content: file}
>
>and
>
>$scope.attachments.body.rows = [{these types of objects}];
>
>
>
>The question is - how can I define my $scope.attachments.body.rows to be this type of array of objects?
>
>I have it currently defined as [] but I am getting some errors because my directive expects certain structure of rows in that array. Originally I had that as part of my model and just passed it when I created a model, but now I removed it from the model and yet still want to create an array in JavaScript that is going to hold that structure.
>
>I did a few quick searches but didn't find an answer to this question.

Something like this, if I understood your question right?...
var YourVariable = new Array(new AnObject());

function AnObject() {
  this.filename = "";
  this.key = "";
  this.type = "";
  this.content = "";
}
----------------------------------
António Tavares Lopes
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform