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

How to reject arrays with unwanted number range
Ruby Array Errors. Input won't enter array issue
Writing an Int-Array to a text file
What is the best way to save/load contents of array to file?
D: Creating an array of templated objects
cURL post json data, json array and image files REST api testing
Tcl array sorting based on values
How do I get all the values from a hash that are in an array?
Get an array dynamicaly from a factory
How to split a string by new lines in Swift
VB.net how to serialize list / array of json objects
How do I convert this hash to an array of hashes?
Define a next_in_line method on Array that takes the element at the beginning of the array and puts it at the end
Best way to calculate means within a MATLAB array based on other values in the array?
Parse the xml array and store the data into array or dictionary using swift
How to select vector elements from each row of a 3D matrix in MATLAB?

Categories

HOME
arrays
sql-server-2008
shopify
vhdl
wmic
angular2-routing
travis-ci
apache2
recyclerview
apple-numbers
image-recognition
cs-cart
equalizer
react-leaflet
mod-pagespeed
aspell
mule-studio
phpbb
alfresco-share
atlassian-plugin-sdk
raphael
autolayout
onsen-ui
pdfsharp
non-deterministic
blackboard
pep8-assembly
piecewise
strophe
read-write
ios-ui-automation
remote-server
.net-assembly
freetts
nsexception
viewgroup
lumen-5.3
ideone
appstore-approval
goquery
workflow-foundation-4.5
decompress
pluck
mcrypt
scd
gce
httplib2
redux-router
android-navigationview
packagemaker
easing
git-annex
spoofing
asteriskami
gradle-eclipse
inotifypropertychanged
uwp-maps
picking
spinlock
eml
magento-1.4
license-key
insertion-sort
self-hosting
eyeql
qbfc
vine
google-plus-one
tilestache
and-operator
method-overriding
emma
visualstatemanager
uipickerviewcontroller
visual-c++-2010-express
sanitization
bigint
javascriptmvc
dig
shortcuts
client-library
graph-coloring
phpsh
tridion2009
pitch
signals2
maven-ant-tasks
selectonemenu
objectbrowser
pivotal-crm
symbol-server
mvccontrib-grid
mvvm-foundation





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