demo_frontend
Version:
Internet Computer starter application
52 lines (41 loc) • 932 B
JavaScript
import Controller from '@ember/controller';
import { action } from '@ember/object';
import { tracked } from '@glimmer/tracking';
import { actor } from 'ember-cli-dfinity';
export default class MainIndexController extends Controller {
name;
valid;
submitting;
greeting;
// Bind to the hello actor deployed to the hello_backend canister using the default agent.
({ canister: 'demo_backend' })
hello;
validity (valid) {
this.valid = valid;
}
async submit () {
try {
this.submitting = true;
this.greeting = await this.hello.greet(this.name);
}
catch (err) {
this.snackbar.showError (err);
}
finally {
this.submitting = false;
}
}
reset () {
this.submitting = false;
this.name = null;
}
get isSubmitButtonDisabled () {
return !this.valid || this.submitting;
}
}