angularJS モデルをビューにデータバインディングするngBind


スポンサーリンク

入力フォームに入力した文字を即時に他の要素に反映させるような処理をしてみます。

<!doctype html>
<html lang="ja" ng-app>
<head>
  <meta charset="utf-8">
  <title>ng-bind</title>
  <script src="./angular.js"></script>
</head>
<body>

  名前:<input type="text" ng-model="name">
  <p ng-bind="name"></p>

</body>
</html>

以下のように、書いた文字が下のp要素にバインドされます。
f:id:sho322:20150416001048j:plain