Fromo mySuccessMethod to myExecuteSubmitMethod (#4573)

In the tutorial, when working with events, it says that we want to show an allert when submitting the login form but in the code just below it binds the allert to the "success" event and not to the "executeSubmit" event. Also calls the method mySuccessMethod and not myExecuteSubmitMethod as it does at the very and of the Tutorial.

So i made the appropriate changes to adjust the code and the tutorial to show how to properly bind an allert to the "eventSubmit" event.

Regards
Luca Biondo
This commit is contained in:
LucaBiondo
2019-04-09 17:50:21 +02:00
committed by Eugenio Romano
parent 2753771d29
commit 3a64f4aaab

View File

@@ -73,23 +73,23 @@ docs, we can see that it emits three events: `success`, `error` and `executeSubm
We can subscribe to these events and have our custom code executed when these events are emitted. Let's hook into the `executeSubmit` and do a simple `alert()` when the form is submitted. We can subscribe to these events and have our custom code executed when these events are emitted. Let's hook into the `executeSubmit` and do a simple `alert()` when the form is submitted.
Open `src/app/login/login.component.html` and add `(success)="mySuccessMethod($event)"` to the `<adf-login/>` component: Open `src/app/login/login.component.html` and add `(executeSubmit)="myExecuteSubmitMethod($event)"` to the `<adf-login/>` component:
```html ```html
<adf-login <adf-login
[showRememberMe]="false" [showRememberMe]="false"
[showLoginActions]="false" [showLoginActions]="false"
(success)="mySuccessMethod($event)" (executeSubmit)="myExecuteSubmitMethod($event)"
copyrightText="© 2017 Alfresco Software, Inc. All Rights Reserved." copyrightText="© 2017 Alfresco Software, Inc. All Rights Reserved."
successRoute="/documentlist"> successRoute="/documentlist">
</adf-login> </adf-login>
``` ```
Next we need to implement `mySuccessMethod` in the typescript. Open `src/app/login/login.component.ts` and add a new method: Next we need to implement `myExecuteSubmitMethod` in the typescript. Open `src/app/login/login.component.ts` and add a new method:
```ts ```ts
// Add this! // Add this!
mySuccessMethod(event: any) { myExecuteSubmitMethod(event: any) {
alert('Form was submitted!'); alert('Form was submitted!');
console.log(event); console.log(event);
} }
@@ -108,7 +108,7 @@ import { Component } from '@angular/core';
export class LoginComponent { export class LoginComponent {
// Add this! // Add this!
mySuccessMethod(event: any) { myExecuteSubmitMethod(event: any) {
alert('Form was submitted!'); alert('Form was submitted!');
console.log(event); console.log(event);
} }