Is it possible to bind click event to an interpolation? because when I am trying to execute the following code I get the following
ERROR Error: Uncaught (in promise):
Error: Template parse errors:
Parser Error: Got interpolation ({{}}) where expression was expected at column 7 in [upload({{config.fileLocation}})]
this is the template where we have faulty interpolation,
<mat-card-actions>
<button mat-raised-button type="button" (click)="upload({{config.fileLocation}})">Upload</button>
</mat-card-actions>
and this is the angular component which is desired to be executed.
upload(location = "/tmp/") {
this.loader.open();
const fileBrowser = this.fileInput.nativeElement;
if (fileBrowser.files && fileBrowser.files[0]) {
const formData: FormData = new FormData();
formData.append('file', fileBrowser.files[0]);
formData.append('data', JSON.stringify({
"method": "filesystem.put",
"params": [location + fileBrowser.files[0].name, { "mode": "493" }]
}));
this.http.post(this.apiEndPoint, formData).subscribe(
(data) => {
this.loader.close();
this.snackBar.open("your files are uploaded", 'close', { duration: 5000 });
},
(error) => {
this.loader.close();
this.dialog.errorReport(error.status, error.statusText, error._body);
}
);
};
}
Just
(click)="upload(config.fileLocation)"
Never use {{}}
together with [foo]="..."
or (bar)="..."
[]
and ()
already mark the attribute as Angular binding. {{}}
also only allows string binding (stringifies every value), while the others allow binding of object values.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments