arrays


Creating an interface with an array of variable length, containing objects in TypeScript/Angular4


I am attempting to create a variable within an in-memory database that contains a TypeScript interface that describes a JSON dataset. This dataset should contain multiple arrays, which in turn contain multiple objects with a fixed length and consistent attributes.
I am writing this in Angular4 and TypeScript. The arrays must be of variable length with a minimum of 1 member
I've written this pseudo code to show you what I mean:
export class MyHomeBrewery {
taps: Array<any> = [{
id: number;
name: string;
type: string;
quantity: number;
}][...];
barrels: Array<any> {
id: number;
name: string;
width: number;
height: number;
quantity: number;
}][...];
I've had a look through the TypeScript and Angular documentation and done a few searches and I can't find the correct syntax for this. Does anyone know?
You should be using them as interfaces as below
export interface MyHomeBrewery {
taps: Array<Taps>;
barrels: Array<Barrels>;
}
export interface Taps {
id: number;
name: string;
type: string;
quantity: number;
}
export interface Barrels {
id : number;
name: string;
width: number;
height: number;
quantity: number;
}

Related Links

forEach loop in Angular 2
Python loop to print salaries within range of the average
How to display this data in twig
How to properly parse a dictionary array
Sort array [[String: Any]] alphabetically in swift 3.0 [duplicate]
In Ruby, how do I execute “select_with_index” on an array?
Is it possible to turn an array to a Result<> in Realm?
MongoDB resolve each ObjectId in an array field to an object from another collection
Play framework, parse json array from request
Swift array of Generics with protocols [duplicate]
How to reverse a given array of numbers in Python 3?
Saving an array of Integers using UserDefaults
delphi Send a file as byte array to a Rest service
Most frequent element in an array (bash 3.2)
User defined function changing each value in an array
swift vapor json response to array

Categories

HOME
arrays
semantic-ui
wildcard
nuxeo
angular2-directives
matplotlib
search-engine
javamail
propertygrid
urlencode
websphere-liberty
netflix-feign
powershell-v3.0
android-source
spinnaker
squarespace
lenskit
riak
quartus
grub2
vs2017
multicore
backpropagation
raphael
tcpclient
rhmap
guile
ggmap
crt
helix-3d-toolkit
postgresql-9.2
reactivemongo
parse-android-sdk
declare
initializer
mongoexport
android-maps-v2
crop
windows-firewall
webdatagrid
info
react-native-fbsdk
mercury
sqlexception
polar-coordinates
createobject
libtiff.net
galleriffic
mongoose-populate
gmsmapview
picking
axes
asymptote
datainputstream
windows-vista
eyeql
retro-computing
visual-studio-code
webhdfs
leadtools-sdk
xjc
guzzle6
hana-xs
java-melody
libsndfile
kendo-mvvm
dalekjs
genetic-programming
code-testing
data-generation
gamepad
bignum
cilk-plus
asp.net-mvc-scaffolding
va-list
dynamic-binding
google-closure-library
device-emulation
android-contextmenu
wpdb
pitch
linkedhashset
cadisplaylink
makefile-project
scraperwiki
galaxy-tab
newsstand-kit
port-scanning
pivotal-crm
zend-form-element
post-redirect-get
visual-c++-2008-express
pci-bus
openvg
usability-testing
weborb
interface-design
cots

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App