I currently have a newsletter subscription that is initially set based on the newsletter I receive when the user logs in.
However, when I toggle the newsletter option, I receive a "successfully updated" message but the newsletter remains set to false even though I changed it to true. Can anyone offer assistance with resolving this issue?
HTML:
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-12 text-center">
<span style="font-weight: 100;">Newsletter{{company.newsletter|json}}</span>
<ul class="toggle">
<li>
<mat-slide-toggle class="showToggle" name="subscribe" [(ngModel)]="company.newsletter" #slider required (click)="openPopup($event,company)">
</mat-slide-toggle>
</li>
</ul>
</div>
Ts:
**Checklogin:**
this.ApiService
.checklogin()
.subscribe(
user => {
this.company= user.data[0];
}, error => {
console.log(error);
});
**newsletter toggle**
openPopup(event,company) {
var userData:any = {
_id: company._id,
email: company.email,
active: company.active,
newsletter:company.newsletter
};
this.ApiService
.editUserToggle(userData._id,userData)
.subscribe(
user => {
console.log(user);
this.toasterService.pop('success', 'User subscribed Successfully');
}, error => {
if(error.data && error.data.length > 0) {
this.toasterService.pop('error', error.data);
} else {
this.toasterService.pop('error', 'Something went wrong!');
}
})
}
Despite receiving a success message, the newsletter still shows as false.