本文整理汇总了TypeScript中ng2-slim-loading-bar.SlimLoadingBarService类的典型用法代码示例。如果您正苦于以下问题:TypeScript SlimLoadingBarService类的具体用法?TypeScript SlimLoadingBarService怎么用?TypeScript SlimLoadingBarService使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SlimLoadingBarService类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: if
this.sub = this.router.events.subscribe(event => {
if (event instanceof NavigationStart) {
this.slimLoader.start();
} else if ( event instanceof NavigationEnd ||
event instanceof NavigationCancel ||
event instanceof NavigationError) {
this.slimLoader.complete();
}
}, (error: any) => {
示例2: handleError
private handleError(error: Response | any) {
this.loadingBar.color = 'red';
this.loadingBar.complete();
let message: string;
if (error instanceof Response) {
if (error.status === 0) {
message = `Could not reach the bhmc server because your internet connection
was lost, the connection timed out, or the server is not responding.`;
} else {
const body = error.json() || {};
if (body.non_field_errors) {
// django-rest-auth
message = body.non_field_errors[0];
} else if (body.username) {
// django-rest-auth
message = body.username[0];
} else if (body.detail) {
// django-rest-framework
message = body.detail;
} else {
message = JSON.stringify(body);
}
}
this.errorHandler.logResponse(message, error);
} else {
this.errorHandler.logError(error);
message = error.message ? error.message : error.toString();
}
this.errorSource.next(message);
return Observable.throw(message);
}
示例3: http
http(options: any) {
let method: string = options.method || 'GET';
let url = options.url ? options.url : '/api' + options.path;
let args = [ url ];
let headers = new Headers();
if (options.data) {
headers.set('Content-Type', 'application/json');
args.push(JSON.stringify(options.data));
}
if (this.authToken) {
headers.set('Authorization', 'Bearer ' + this.authToken);
}
let query = new URLSearchParams();
if (options.query) {
_.each(options.query, function(value, key) {
query.set(key, value);
});
}
args.push(new RequestOptions({
headers: headers,
search: query
}));
this.slimLoader.height = '4px';
this.slimLoader.start();
return this._http[method.toLowerCase()].apply(this._http, args).finally(() => {
this.slimLoader.complete();
});
}
示例4: ngOnInit
public ngOnInit() {
// Mouseflow integration
if ((window as any)._mfq) {
(window as any)._mfq.push(['newPageView', '/appointment/patient']);
}
// Set up page
this._state.isSubPage.next(true);
this._state.title.next();
this._state.actions.next();
this._state.primaryAction.next();
// Retrieve patient to be displayed from route and retrieve data from service
const param: string = this.route.snapshot.params['id'];
this.slimLoadingBarService.start();
this.patientService.patientFindById(param)
.subscribe(
(patient) => {
this.patient = patient;
this._state.title.next(patient.givenName + ' ' + patient.surname);
this.findAppointmentsForPatient(this.patient.id);
},
(err) => console.log(err)
);
// Set up localized humanizer for durations
this.localeHumanizer = humanizeDuration.humanizer({
language: localStorage.getItem('locale').startsWith('de') ? 'de' : 'en'
});
}
示例5: ngOnInit
public ngOnInit() {
// Mouseflow integration
if ((window as any)._mfq) {
(window as any)._mfq.push(['newPageView', '/appointment/accept']);
}
// Set up page
this._state.isSubPage.next(true); // TODO block this #114
this._state.title.next(
localStorage.getItem('locale').startsWith('de') ? 'Terminbestätigung' : 'Accept Appointment');
this._state.actions.next();
this._state.primaryAction.next();
// Retrieve data
this.slimLoadingBarService.start();
this.appointmentService.appointmentAcceptOffer(this.route.snapshot.params['secret'])
.subscribe(
(appointment) => this.acceptedAppointment = appointment,
(err) => {
console.log(err);
if (err._body.error.status === 404 && err._body.error.code === 'NOT_FOUND_OR_EXPIRED') {
this.failed = true;
} else {
console.log(err);
}
},
() => {
this.slimLoadingBarService.complete();
console.log('Accepted offer successfully.');
}
);
}
示例6: runSlimLoader
private runSlimLoader(): void {
this.slimLoader.start();
setTimeout(() => this.slimLoader.progress = 14, 200);
setTimeout(() => this.slimLoader.progress = 17, 400);
setTimeout(() => this.slimLoader.progress = 20, 500);
setTimeout(() => this.slimLoader.complete(), 800);
}
示例7: searchMovie
searchMovie(title: string) {
this.slimLoader.start();
this.movieService.searchMovie(title)
.subscribe(res => this.movieSearchResults = res.results,
(error: any) => console.log(error),
() => this.slimLoader.complete()
);
}
示例8: catch
.map((response: Response) => {
this.loadingBar.color = 'green';
this.loadingBar.complete();
try {
return response.json() || {};
} catch(e) {
return {};
}
})
示例9: requestHelper
private requestHelper(additionalOptions?:RequestOptions){
this.loading.start(() => {
});
let options:RequestOptions = ApiAuth.createHttpOptions();
if (additionalOptions) {
options = options.merge(additionalOptions);
}
let req = this.http.request(new Request(options));
req.subscribe(res => this.HandleReponse(res), error => this.HandleError(error));
return req;
}
示例10: request
request(method: RequestMethod, url: string, data?: any) {
this.loadingBar.color = 'blue';
this.loadingBar.start();
let options = this.createOptions(method, data);
return this.http.request(url, options)
.map((response: Response) => {
this.loadingBar.color = 'green';
this.loadingBar.complete();
try {
return response.json() || {};
} catch(e) {
return {};
}
})
.catch((err: any) => this.handleError(err));
}