11
modules/examples/src/jsonp/index.html
Normal file
11
modules/examples/src/jsonp/index.html
Normal file
@ -0,0 +1,11 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<title>Hello Jsonp</title>
|
||||
<body>
|
||||
<jsonp-app>
|
||||
Loading...
|
||||
</jsonp-app>
|
||||
|
||||
$SCRIPTS$
|
||||
</body>
|
||||
</html>
|
12
modules/examples/src/jsonp/index.ts
Normal file
12
modules/examples/src/jsonp/index.ts
Normal file
@ -0,0 +1,12 @@
|
||||
/// <reference path="../../../angular2/typings/rx/rx.all.d.ts" />
|
||||
|
||||
import {bootstrap} from 'angular2/angular2';
|
||||
import {reflector} from 'angular2/src/reflection/reflection';
|
||||
import {ReflectionCapabilities} from 'angular2/src/reflection/reflection_capabilities';
|
||||
import {jsonpInjectables} from 'angular2/http';
|
||||
import {JsonpCmp} from './jsonp_comp';
|
||||
|
||||
export function main() {
|
||||
reflector.reflectionCapabilities = new ReflectionCapabilities();
|
||||
bootstrap(JsonpCmp, [jsonpInjectables]);
|
||||
}
|
11
modules/examples/src/jsonp/index_dynamic.html
Normal file
11
modules/examples/src/jsonp/index_dynamic.html
Normal file
@ -0,0 +1,11 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<title>Angular 2.0 Jsonp (Reflection)</title>
|
||||
<body>
|
||||
<jsonp-app>
|
||||
Loading...
|
||||
</jsonp-app>
|
||||
|
||||
$SCRIPTS$
|
||||
</body>
|
||||
</html>
|
13
modules/examples/src/jsonp/index_dynamic.ts
Normal file
13
modules/examples/src/jsonp/index_dynamic.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import {JsonpCmp} from './jsonp_comp';
|
||||
import {bootstrap} from 'angular2/angular2';
|
||||
import {reflector} from 'angular2/src/reflection/reflection';
|
||||
import {ReflectionCapabilities} from 'angular2/src/reflection/reflection_capabilities';
|
||||
import {jsonpInjectables} from 'angular2/http';
|
||||
|
||||
|
||||
export function main() {
|
||||
// This entry point is not transformed and exists for testing purposes.
|
||||
// See index.js for an explanation.
|
||||
reflector.reflectionCapabilities = new ReflectionCapabilities();
|
||||
bootstrap(JsonpCmp, [jsonpInjectables]);
|
||||
}
|
23
modules/examples/src/jsonp/jsonp_comp.dart
Normal file
23
modules/examples/src/jsonp/jsonp_comp.dart
Normal file
@ -0,0 +1,23 @@
|
||||
library examples.src.jsonp.jsonp_comp;
|
||||
|
||||
import "package:angular2/angular2.dart" show Component, View, NgFor;
|
||||
import "package:angular2/http.dart" show Jsonp;
|
||||
import "package:angular2/src/facade/async.dart" show ObservableWrapper;
|
||||
|
||||
@Component(selector: "jsonp-app")
|
||||
@View(directives: const [NgFor], template: '''
|
||||
<h1>people</h1>
|
||||
<ul class="people">
|
||||
<li *ng-for="#person of people">
|
||||
hello, {{person[\'name\']}}
|
||||
</li>
|
||||
</ul>
|
||||
''')
|
||||
class JsonpCmp {
|
||||
Object people;
|
||||
JsonpCmp(Jsonp jsonp) {
|
||||
ObservableWrapper.subscribe(
|
||||
jsonp.get("./people.json?callback=JSONP_CALLBACK"),
|
||||
(res) => this.people = res.json().toList());
|
||||
}
|
||||
}
|
23
modules/examples/src/jsonp/jsonp_comp.ts
Normal file
23
modules/examples/src/jsonp/jsonp_comp.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import {Component, View, NgFor} from 'angular2/angular2';
|
||||
import {Jsonp} from 'angular2/http';
|
||||
import {ObservableWrapper} from 'angular2/src/facade/async';
|
||||
|
||||
@Component({selector: 'jsonp-app'})
|
||||
@View({
|
||||
directives: [NgFor],
|
||||
template: `
|
||||
<h1>people</h1>
|
||||
<ul class="people">
|
||||
<li *ng-for="#person of people">
|
||||
hello, {{person['name']}}
|
||||
</li>
|
||||
</ul>
|
||||
`
|
||||
})
|
||||
export class JsonpCmp {
|
||||
people: Object;
|
||||
constructor(jsonp: Jsonp) {
|
||||
ObservableWrapper.subscribe(jsonp.get('./people.json?callback=JSONP_CALLBACK'),
|
||||
res => this.people = res.json());
|
||||
}
|
||||
}
|
2
modules/examples/src/jsonp/people.json
Normal file
2
modules/examples/src/jsonp/people.json
Normal file
@ -0,0 +1,2 @@
|
||||
// This can only be requested once due to constant method name :(
|
||||
__ng_jsonp__.__req0.finished([{"name":"caitp"}])
|
Reference in New Issue
Block a user