起步

下载模板:

  1. git clone https://github.com/tastejs/todomvc-app-template.git --depth 1

初始化项目:

  1. ng new todomvc-angular
  2. cd todomvc-angular
  3. ng serve

todomvc-angular\src\app\app.component.html 文件内容替换如下:

  1. <section class="todoapp">
  2. <header class="header">
  3. <h1>todos</h1>
  4. <input class="new-todo" placeholder="What needs to be done?" autofocus>
  5. </header>
  6. <!-- This section should be hidden by default and shown when there are todos -->
  7. <section class="main">
  8. <input id="toggle-all" class="toggle-all" type="checkbox">
  9. <label for="toggle-all">Mark all as complete</label>
  10. <ul class="todo-list">
  11. <!-- These are here just to show the structure of the list items -->
  12. <!-- List items should get the class `editing` when editing and `completed` when marked as completed -->
  13. <li class="completed">
  14. <div class="view">
  15. <input class="toggle" type="checkbox" checked>
  16. <label>Taste JavaScript</label>
  17. <button class="destroy"></button>
  18. </div>
  19. <input class="edit" value="Create a TodoMVC template">
  20. </li>
  21. <li>
  22. <div class="view">
  23. <input class="toggle" type="checkbox">
  24. <label>Buy a unicorn</label>
  25. <button class="destroy"></button>
  26. </div>
  27. <input class="edit" value="Rule the web">
  28. </li>
  29. </ul>
  30. </section>
  31. <!-- This footer should hidden by default and shown when there are todos -->
  32. <footer class="footer">
  33. <!-- This should be `0 items left` by default -->
  34. <span class="todo-count"><strong>0</strong> item left</span>
  35. <!-- Remove this if you don't implement routing -->
  36. <ul class="filters">
  37. <li>
  38. <a class="selected" href="#/">All</a>
  39. </li>
  40. <li>
  41. <a href="#/active">Active</a>
  42. </li>
  43. <li>
  44. <a href="#/completed">Completed</a>
  45. </li>
  46. </ul>
  47. <!-- Hidden if no completed items are left ↓ -->
  48. <button class="clear-completed">Clear completed</button>
  49. </footer>
  50. </section>
  51. <footer class="info">
  52. <p>Double-click to edit a todo</p>
  53. <!-- Remove the below line ↓ -->
  54. <p>Template by <a href="http://sindresorhus.com">Sindre Sorhus</a></p>
  55. <!-- Change this out with your name and url ↓ -->
  56. <p>Created by <a href="http://todomvc.com">you</a></p>
  57. <p>Part of <a href="http://todomvc.com">TodoMVC</a></p>
  58. </footer>

安装模板依赖的样式文件:

  1. npm install todomvc-app-css

todomvc-angular\src\styles.css 文件中导入样式文件:

  1. /* You can add global styles to this file, and also import other style files */
  2. @import url('../node_modules/todomvc-app-css/index.css');

看到如下页面说明成功。

todomvc-angular