nested_props.html 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. Seed.controller('test', function (scope) {
  17. // set the data any way you want.
  18. scope.one = function () {
  19. scope.a = {
  20. c: 1,
  21. b: {
  22. c: 'one'
  23. }
  24. }
  25. }
  26. scope.two = function () {
  27. scope.a.b = {
  28. c: 'two'
  29. }
  30. scope.a.c = 2
  31. }
  32. scope.three = function () {
  33. scope.a.b.c = 'three'
  34. scope.a.c = 3
  35. }
  36. // computed properties also works!!!!
  37. scope.d = {get: function () {
  38. return (scope.a.b.c + scope.a.c) || ''
  39. }}
  40. })
  41. var app = Seed.bootstrap()
  42. </script>
  43. </body>
  44. </html>