I have been wracking my brain on this for some time and cannot for the life of me figure out what is wrong. I am somewhat of an Angular novice so it's extremely possible I could be doing something wrong that's really obvious. I have the following code:
bucket.component.html
<div class="container">
<div class="row">
<div class="col s12">
<div id="backButton">
<a class="valign-wrapper" (click)="navigateBack()"><i class="material-icons">arrow_back</i> Back</a>
</div>
<h2 class="center-align" id="title">{{ name }}</h2>
</div>
</div>
<div class="row">
<div class="col s12" *ngFor="let object of objects">
<app-bucket-file [key]="object.Key" [lastModified]="object.LastModified" [size]="object.Size" [owner]="object.Owner.DisplayName"></app-bucket-file>
</div>
</div>
</div>
bucket-file.component.html
<div class="card valign-wrapper">
<div class="card-content white-text">
<span class="card-title">{{ key }}</span>
<p>Last Modified: {{ lastModified | date:'short' }}</p>
<p>Size: {{ conversion(size, 2) }}</p>
<p>Owner: {{ owner }}</p>
</div>
</div>
bucket-file.component.ts
import {Component, Input, OnInit} from '@angular/core';
@Component({
selector: 'app-bucket-file',
templateUrl: './bucket-file.component.html',
styleUrls: ['./bucket-file.component.css']
})
export class BucketFileComponent implements OnInit {
@Input() key: string;
@Input() lastModified: string;
@Input() size: number;
@Input() owner: string;
public conversion = BucketFileComponent.bytesToSize;
constructor() { }
ngOnInit() {
console.log('Key:' + this.key);
}
public static bytesToSize(bytes: number, decimals: number) {
const sizes = ['Bytes', 'KB', 'MB', 'GB,', 'TB'];
if (bytes === 0) {
return '0 Bytes';
}
const k = 1024,
dm = decimals <= 0 ? 0 : decimals || 2,
i = Math.floor(Math.log(bytes) / Math.log(k));
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
}
}
The console.log works in bucket-file.component.ts ngOnInit() and returns the correct values, so I know that the input is working to some degree. However, when I try to display it in the template HTML I get nothing. No errors either. i am really confused as to what I am doing wrong. Any help would be much appreciated.
Thanks