1234567891011121314151617181920212223242526272829303132 |
- <html>
- <head>
- <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/2.0.0-beta.14/angular2-polyfills.min.js"></script>
- <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/2.0.0-beta.14/Rx.umd.min.js"></script>
- <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/2.0.0-beta.14/angular2-all.umd.min.js"></script>
- <script src="../lib/php_crud_api_transform.js"></script>
- <script>
- AppComponent =
- ng.core.Component({
- selector: 'my-app',
- providers: [ng.http.HTTP_PROVIDERS],
- template: '<ul><li *ngFor="#x of posts">{{ x.id + ", " + x.content }}</li></ul>'
- })
- .Class({
- constructor: [
- ng.http.Http, function(http) {
- var url = "../api.php/posts";
- http.post(url,JSON.stringify({user_id:1,category_id:1,content:"from angular2"})).subscribe();
- http.get(url).map(res => php_crud_api_transform(res.json())).subscribe(res => this.posts = res.posts);
- }
- ]
- });
- document.addEventListener("DOMContentLoaded", function(event) {
- ng.core.enableProdMode();
- ng.platform.browser.bootstrap(AppComponent);
- });
- </script>
- </head>
- <body>
- <my-app>Loading...</my-app>
- </body>
- </html>
|