I can't understand why my function cal is multiplying every time i came on 
this page. my code:
```
import { Component, EventEmitter, Input, OnInit, OnDestroy, ViewChild, 
AfterViewInit } from '@angular/core';
import { ActivatedRoute, Params, Router } from '@angular/router';

import { FooterService } from '../../services/footer.service';
import {Subscription} from 'rxjs/Subscription';

@Component({
    selector: 'manage-broker',
    templateUrl: '/app/components/brokers/broker.component.html'
})

export class BrokerComponent implements OnInit, AfterViewInit, OnDestroy {
    subscription: Subscription;

    ngOnInit(): void {
        this.subscription = this.footerService.submit$.subscribe(value => 
value === true ? this.onSubmit() : null);
        this.subscription = this.footerService.sendMail$.subscribe(value => 
value === true ? this.popup.open() : null);
    }

    onSubmit(): void {
        this.footerService.setSubmit(false);
        this.brokerService.save(this.broker).then(response => 
this.backToList());
    }

    ngOnDestroy() {
        this.subscription.unsubscribe();
    }

}

```
My problem is cuz each time i came on this page the onSubmit function call 
is grows like first time is called one, second time i came on this page is 
called twice etc.
If i refres my browser CTRL+R. the counter is back to 1 and restart the 
same behaivor.
Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to