I'm trying to do a simple TODO sample with angular.js (using routes). I could open the form to create a New Task, but when I click on "Back" button (after create a new one), it always crashes my browser.
I've tried config the '/' route and use .otherwise too, but I'm still getting the same result.
What I'm doing wrong?
//listTasks.htm
<!DOCTYPE html>
<html data-ng-app="appTodoList">
<head>
<title>TODO List</title>
</head>
<body>
<div data-ng-controller="TodoCtrl">
<a href="#/new">New Task</a>
<ul id="listTasks">
<li data-ng-repeat="task in tasks">{{ task.name }}</li>
</ul>
</div>
<div>
<div data-ng-view=""></div>
</div>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.6/angular.min.js"></script>
<script type="text/javascript" src="http://code.angularjs.org/1.2.6/angular-route.min.js"></script>
<script type="text/javascript">
var app = angular.module("appTodoList",['ngRoute']);
app.config(function ($routeProvider)
{
$routeProvider
.when('/list',
{
controller:'TodoCtrl',
templateUrl: 'listTasks.htm'
})
.when('/new',
{
controller:'TodoCtrl',
templateUrl: 'newTask.htm'
});
});
app.controller('TodoCtrl', function($scope)
{
$scope.tasks = [];
$scope.addTask = function ()
{
$scope.tasks.push({name: $scope.new.TaskName});
};
});
</script>
</body>
</html>
//newTask.htm
<div>
<input type="text" data-ng-model="new.TaskName" id="txtTaskName" placeholder="Task" />
<input type="button" id="btnAdd" value="Add" data-ng-click="addTask()">
</div>
<a href="#/list">Back</a>
PS: I'm using Firefox 26