async ngOnInit(): Promise<void> { let workInfo = <IUserWorkInformation>{}; await…
- User
async ngOnInit(): Promise { let workInfo = {}; await this._userService .getUserWorkInformation( this._contextService.currentUser.Id, new Date().getDay() ) .then((data) => { workInfo = data; }); this._storage.list(NeonCoreApiControllers.Cities).then((x) => { x = x.filter((row) => row.Code != this._cityUtils.getUnknownCity().Code); if (this.remoteWork) x.push(this._cityUtils.getUnknownCity()); this.cityItems = x; const branch = this.cityItems.filter( (c) => c.Code == this._cityUtils.getCityCode(workInfo.AddressWorkplace) )[0]; if (branch && !this.remoteWork) { this.selectedCity = branch; } else { this.selectedCity = this._cityUtils.getUnknownCity(); this.showAdds = true; } }); }
исправь
- Assistant
async ngOnInit(): Promise { let workInfo = {}; await this._userService .getUserWorkInformation( this._contextService.currentUser.Id, new Date().getDay() ) .then((data) => { workInfo = data; }); this._storage.list(NeonCoreApiControllers.Cities).then((x) => { x = x.filter((row) => row.Code !== this._cityUtils.getUnknownCity().Code); if (this.remoteWork) { x.push(this._cityUtils.getUnknownCity()); } this.cityItems = x; const branch = this.cityItems.filter( (c) => c.Code === this._cityUtils.getCityCode(workInfo.AddressWorkplace) )[0]; if (branch && !this.remoteWork) { this.selectedCity = branch; } else { this.selectedCity = this._cityUtils.getUnknownCity(); this.showAdds = true; } }); }
- User
что изменилось
- Assistant
Я исправил следующие вещи в функции
ngOnInit():- Добавил фигурные скобки вокруг условия
if, чтобы оно было более явным. - Изменил операторы сравнения
!=на!==и==на===, чтобы сравнение происходило как по значению, так и по типу. - Добавил фигурные скобки вокруг условия
if, чтобы оно было более явным. - Добавил фигурные скобки вокруг блока кода, следующего за условным оператором
if, чтобы он был более явным.
- Добавил фигурные скобки вокруг условия