|
| 1 | +<!doctype html> |
| 2 | +<html> |
| 3 | + <head> |
| 4 | + <meta charset="utf-8" /> |
| 5 | + <title>AngularTS</title> |
| 6 | + <link rel="shortcut icon" type="image/png" href="images/favicon.ico" /> |
| 7 | + <script type="module" src="/src/index.js"></script> |
| 8 | + <script> |
| 9 | + document.addEventListener("DOMContentLoaded", () => { |
| 10 | + class Todo { |
| 11 | + constructor(task) { |
| 12 | + this.task = task; |
| 13 | + this.done = false; |
| 14 | + } |
| 15 | + } |
| 16 | + class TodoController { |
| 17 | + constructor() { |
| 18 | + this.greeting = "Todos"; |
| 19 | + this.model = { |
| 20 | + name: "John", |
| 21 | + lastName: "Doe", |
| 22 | + }; |
| 23 | + this.tasks = [ |
| 24 | + new Todo("Learn AngularTS"), |
| 25 | + new Todo("Build an AngularTS app"), |
| 26 | + ]; |
| 27 | + } |
| 28 | + |
| 29 | + get() { |
| 30 | + return this.counter; |
| 31 | + } |
| 32 | + |
| 33 | + increase() { |
| 34 | + console.log(this); |
| 35 | + this.counter++; |
| 36 | + } |
| 37 | + |
| 38 | + /** |
| 39 | + * @param {String} task |
| 40 | + * @return {void} |
| 41 | + */ |
| 42 | + add(task) { |
| 43 | + this.tasks.push(new Todo(task)); |
| 44 | + } |
| 45 | + |
| 46 | + /** |
| 47 | + * Delete all finished tasks |
| 48 | + * @return {void} |
| 49 | + */ |
| 50 | + archive() { |
| 51 | + let newTasks = this.tasks.filter((task) => !task.done); |
| 52 | + this.tasks = newTasks; |
| 53 | + } |
| 54 | + } |
| 55 | + |
| 56 | + class Demo { |
| 57 | + constructor($eventBus, $scope, adder) { |
| 58 | + this.adder = adder; |
| 59 | + } |
| 60 | + |
| 61 | + async test() { |
| 62 | + this.y = (await this.adder).add(1, 2); |
| 63 | + } |
| 64 | + } |
| 65 | + window.angular |
| 66 | + .module("todo", []) |
| 67 | + .controller("TodoCtrl", TodoController) |
| 68 | + .controller("DemoCtrl", Demo) |
| 69 | + .wasm("adder", "/src/directive/wasm/math.wasm"); |
| 70 | + }); |
| 71 | + </script> |
| 72 | + |
| 73 | + <style> |
| 74 | + .fade { |
| 75 | + background-color: red; |
| 76 | + } |
| 77 | + /* The starting CSS styles for the enter animation */ |
| 78 | + .fade.ng-enter { |
| 79 | + transition: 0.5s linear all; |
| 80 | + background-color: unset; |
| 81 | + opacity: 0; |
| 82 | + } |
| 83 | + |
| 84 | + /* The finishing CSS styles for the enter animation */ |
| 85 | + .fade.ng-enter.ng-enter-active { |
| 86 | + opacity: 1; |
| 87 | + background-color: red; |
| 88 | + } |
| 89 | + |
| 90 | + /* The starting CSS styles for the leave animation */ |
| 91 | + .fade.ng-leave { |
| 92 | + transition: 0.5s linear all; |
| 93 | + opacity: 1; |
| 94 | + } |
| 95 | + |
| 96 | + /* The finishing CSS styles for the leave animation */ |
| 97 | + .fade.ng-leave.ng-leave-active { |
| 98 | + opacity: 0; |
| 99 | + background-color: unset; |
| 100 | + } |
| 101 | + </style> |
| 102 | + </head> |
| 103 | + <body ng-app="todo"> |
| 104 | + <div ng-controller="DemoCtrl as $ctrl"> |
| 105 | + {{ $ctrl.y }} |
| 106 | + <button ng-click="$ctrl.test()">test</button> |
| 107 | + </div> |
| 108 | + <ng-wasm src="/src/directive/wasm/math.wasm" as="demo1"></ng-wasm> |
| 109 | + <input type="number" ng-model="a" ng-keyup="x = demo1.add(a, b)" /> |
| 110 | + <input type="number" ng-model="b" ng-keyup="x = demo1.add(a, b)" /> |
| 111 | + {{ x }} |
| 112 | + </body> |
| 113 | +</html> |
0 commit comments