/
githubmirror
/
angular
Обзор
Документация
Войти
/
githubmirror
/
angular
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
modules/playground/src/jsonp/app/jsonp_comp.ts
37 строк
898 B
SkyZeroZx
fix(http): Rejects non-HTTP(S) URLs in JSONP requests
06 июн 2026, 01:09
06 июн 2026, 01:09
255151a
Код
Авторство
О чём код?
/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ import {HttpClient} from '@angular/common/http'; import {ChangeDetectionStrategy, Component} from '@angular/core'; interface Person { name: string; } @Component({ selector: 'jsonp-app', template: ` <h1>people</h1> <ul class="people"> <li *ngFor="let person of people">hello, {{ person.name }}</li> </ul> `, standalone: false, changeDetection: ChangeDetectionStrategy.Eager, }) export class JsonpCmp { people: Person[] = []; constructor(http: HttpClient) { const peopleUrl = new URL('./people.json', window.location.href).toString(); http.jsonp(peopleUrl, 'callback').subscribe((res: unknown) => { this.people = res as Person[]; }); } }