Очистить локальное хранилище, когда не работает кнопка выхода из системы, также я не делаю это с файлами контроллера. Я использую только .ts и .HTML .Функция изготовления Есть ли способ сделать это без функции тоже?Любая особенность Angular?
Вот мой HTML-файл
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 19.315" width="20">
<g id="logout" transform="translate(0
-1.66)" > </svg>
Вот мой ts файл
public articlepara = { clientid: localStorage.getItem('storageselectedclient'), page: 1, type: 'All', keytype: '', sortdate: 'asc', sortpub: '', sortnews: '', fromdate: this.fromdate, todate: this.todate, publicationFilter: '', sortprominence: '' }
user = {
email: localStorage.getItem('email')
}
constructor(public article: ArticleService, http: HttpClient, elementRef: ElementRef, public _client: ClientService, private spinnerService: Ng4LoadingSpinnerService, private helper: HelperService, excelService: ExcelService, private filterPipe: FilterPipe) {
}
ngOnInit() {
$("#reset").hide();
var self = this;
// $(document).ready(function(){
$("#dateclick").click(function () {
$('#rangeCal').toggle();
})
updateConfig();
function updateConfig() {
var options: { dateLimit: String } = {
dateLimit: ""
//,minDate: moment().subtract(365, 'days') , maxDate: moment()
};
$('#config-demo').daterangepicker(options, function (start, end, label) {
var startDateRange = end.format('YYYY-MM-DD');
var endDateRange = start.format('YYYY-MM-DD');
self.articlepara.todate = endDateRange;
self.articlepara.fromdate = startDateRange;
self.spinnerService.show();
self.isActiveToday = false;
self.isActive7Days = false;
self.isActiveYesterday = false;
self.isActivedaterange = true;
});
}
// });
this.articlepara.type = 'ALL';
this.articlepara.keytype = '';
// this.articlepara.prominance = '';
// this.articlepara.company = '';
// this.articlepara.author = '';
this.articlepara.publicationFilter = '';
this.Clients(); //uncomment for client list
this.selectedclient = localStorage.getItem('storageselectedclient');
this.spinnerService.show();
}
Clients() {
//console.log(this.user);
// this.spinnerService.show();
this._client.getClients(this.user)
.subscribe(
res => {
// console.log(res);
this.clientlist = res;
},
err => {
console.log(err);
},
() => {
// this.getallarticles();
this.spinnerService.show();
this.getUserDetails();
}
)
}
getUserDetails() {
var postData = {
clientid: localStorage.getItem('storageselectedclient'),
email: localStorage.getItem('email')
}
this.article.getUserDetails(postData)
.subscribe(
res => {
// console.log(res);
this.userdetails = res[0];
},
err => {
console.log(err);
}
)
this.getUserClientDetails();
}
getUserClientDetails() {
var postData = {
clientid: localStorage.getItem('storageselectedclient')
}
this.article.getUserClientDetails(postData)
.subscribe(
res => {
// console.log(res);
this.userClientdetails = res[0];
this.spinnerService.hide();
},
err => {
console.log(err);
}
)
}
//=======================change selectd client form dropdownlist=============================//
changeclient(value) {
localStorage.setItem('storageselectedclient', value);
localStorage.removeItem('storageselectedclient')
this.spinnerService.show();
this.getUserDetails();
}