ドットインストールの「AngularJSで作るToDoアプリ」の「#02 ToDoを追加していこう」を実際にやってみているのですが、addNew()でリストを追加する動作が行えません。ご教授お願いいたします。
index.html
<!DOCTYPE html> <html lang="ja" ng-app="formExample"> <head> <meta charset="UTF-8"> <title>Angularの練習</title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js"></script> <script src="myscript.js"></script> </head> <body> <h1>TODOLIST</h1> <div ng-controller="ExampleController"> <ul> <li ng-repeat="task in tasks"> <input type="checkbox" ng-model="task.done"> <span class="done-{{task.done}}"> {{task.body}}</span> </li> </ul> <form ng-submit="addNew()"> <input type="text" ng-model="newTaskBody"> <input type="submit" value="add"> </form> </div> </div> </body> </html>
myscript.js
angular.module('formExample', []) .controller('ExampleController', ['$scope', function($scope) { $scope.tasks= [ {"body":"do this 1", "done":false}, {"body":"do this 2", "done":false}, {"body":"do this 3", "done":true}, {"body":"do this 4", "done":false}, ]; $scope.addNew= funcion(){ $scope.tasks.push({"body":$scope.newTaskBody, "done":false}); $scope.newTaskBody =''; } }]);
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/06/18 22:37