2
0

nested_props.html 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <title></title>
  5. <meta charset="utf-8">
  6. <script src="../dist/seed.js"></script>
  7. </head>
  8. <body sd-controller="test">
  9. <h1>a.b.c : {{a.b.c}}</h1>
  10. <h2>a.c : {{a.c}}</h2>
  11. <h3>Computed property that concats the two: {{d}}</h3>
  12. <button sd-on="click:one">one</button>
  13. <button sd-on="click:two">two</button>
  14. <button sd-on="click:three">three</button>
  15. <script>
  16. var Seed = require('seed')
  17. Seed.controller('test', function (scope) {
  18. // set the data any way you want.
  19. scope.one = function () {
  20. scope.a = {
  21. c: 1,
  22. b: {
  23. c: 'one'
  24. }
  25. }
  26. }
  27. scope.two = function () {
  28. scope.a.b = {
  29. c: 'two'
  30. }
  31. scope.a.c = 2
  32. }
  33. scope.three = function () {
  34. scope.a.b.c = 'three'
  35. scope.a.c = 3
  36. }
  37. // computed properties also works!!!!
  38. scope.d = {get: function () {
  39. return (scope.a.b.c + scope.a.c) || ''
  40. }}
  41. })
  42. var app = Seed.bootstrap()
  43. </script>
  44. </body>
  45. </html>