api de gestion de ticket, basé sur php-crud-api. Le but est de décorrélé les outils de gestion des données, afin
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

client_angular2_auth.html 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <html>
  2. <head>
  3. <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/2.0.0-beta.14/angular2-polyfills.min.js"></script>
  4. <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/2.0.0-beta.14/Rx.umd.min.js"></script>
  5. <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/2.0.0-beta.14/angular2-all.umd.min.js"></script>
  6. <script src="../lib/php_crud_api_transform.js"></script>
  7. <script>
  8. AppComponent =
  9. ng.core.Component({
  10. selector: 'my-app',
  11. providers: [ng.http.HTTP_PROVIDERS],
  12. template: '<ul><li *ngFor="#x of posts">{{ x.id + ", " + x.content }}</li></ul>'
  13. })
  14. .Class({
  15. constructor: [
  16. ng.http.Http, function(http) {
  17. // add withCredentials
  18. let _build = http._backend._browserXHR.build;
  19. http._backend._browserXHR.build = () => {
  20. let _xhr = _build();
  21. _xhr.withCredentials = true;
  22. return _xhr;
  23. };
  24. var url = "../api.php";
  25. http.post(url,JSON.stringify({username:"admin",password:"admin"})).subscribe(res => {
  26. url += "/posts?csrf="+JSON.parse(res._body);
  27. http.post(url,JSON.stringify({user_id:1,category_id:1,content:"from angular2"})).subscribe();
  28. http.get(url).map(res => php_crud_api_transform(res.json())).subscribe(res => this.posts = res.posts);
  29. });
  30. }
  31. ]
  32. });
  33. document.addEventListener("DOMContentLoaded", function(event) {
  34. ng.core.enableProdMode();
  35. ng.platform.browser.bootstrap(AppComponent);
  36. });
  37. </script>
  38. </head>
  39. <body>
  40. <my-app>Loading...</my-app>
  41. </body>
  42. </html>