emberJs tutorial における、angularJs との違い

イシュー

参考

angularJsとの違い

属性の指定方法

angular
<span ng-bind="name"></span>
ember
<span {{bind-attr class="isCompleted:completed"}}></span>
  • bind-attr ヘルパーを使用する

actionの指定方法

angular
<div ng-controller="DoubleCtrl">
  Two times <input ng-model="num"> equals {{ double(num) }}
</div>
ember
<script type="text/x-handlebars" data-template-name="todos">
{{input type="text" id="new-todo" placeholder="What needs to be done?" 
              value=newTitle action="createTodo"}}
</script>
  • emberの場合、コントローラの指定はテンプレートのdata-template-name属性に記載する。
  • 上記の場合、テンプレート名にtodosを指定しているので、todos_controller.jsをCoCでバインドしてくれる。
  • 上記inputヘルパーの場合、読み込んでいるコントローラの action 内で定義している、createTodoというメソッドを呼び出せる
<!--- ... additional lines truncated for brevity ... -->
{{#each itemController="todo"}}
  <li {{bind-attr class="isCompleted:completed"}}>
    {{input type="checkbox" checked=isCompleted class="toggle"}}
    <label>{{title}}</label><button class="destroy"></button>
  </li>
{{/each}}
<!--- ... additional lines truncated for brevity ... -->
  • each ヘルパーのitemController 属性を使用した場合

子ルートの追加(Lesson16 Outlet)

ember
 {{outlet}}
Angular
<div ng-view ></div>
参考