We are doing a comparison between knockout and angular to help make a determination about which to use for binding. Since I'm not a current developer in either, I just wanted to put together a simple single html page (index.html) without multiple views to do this comparison. To make this happen, I viewed a simple jsfiddle regarding a knockout hello world example, copied the source from the page, pasted it in an index.html, changed the script reference paths, and served it up. No problems I was able to start using a knockout app in a single file to start testing.
Tried to do the same thing with Angular and I keep getting errors that make me unsure what the problem is. Here is the example. Can anyone tell me what I'm doing wrong? The jsfiddle example is: http://jsfiddle.net/Hp4W7/637/
Here is the code. The error is below.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Scroll + limitTo - jsFiddle demo</title>
<script type='text/javascript' src='scripts/angular.js'></script>
<script type='text/javascript'>//<![CDATA[
var app = angular.module('app', []);
function Ctrl($scope) {
$scope.tasks = [{id:1,'name':'test1'}, {id:2,'name':'test2'}, {id:3,'name':'test3'}];
$scope.removeTask = function(taskId){
alert("Task Id is "+taskId);
};
}
//]]>
</script>
</head>
<body ng-app="app">
<div class="test" ng-controller="Ctrl">
<div ng-repeat="task in tasks">
<button ng-click="removeTask(task.id);">remove</button>
</div>
</div>
</body>
</html>
And here is the error message.
Error: [ng:areq] Argument 'Ctrl' is not a function, got undefined http://errors.angularjs.org/1.3.0-rc.5/ng/areq?p0=Ctrl&p1=not%20a%20function%2C%20got%20undefined at assertArg (http://myhost/angulartest/scripts/angular.js:1609:5) at assertArgFn (http://myhost/angulartest/scripts/angular.js:1619:3) at Anonymous function (http://myhost/angulartest/scripts/angular.js:8074:9) at Anonymous function (http://myhost/angulartest/scripts/angular.js:7251:13) at forEach (http://myhost/angulartest/scripts/angular.js:343:11) at nodeLinkFn (http://myhost/angulartest/scripts/angular.js:7238:11) at compositeLinkFn (http://myhost/angulartest/scripts/angular.js:6746:13) at compositeLinkFn (http://myhost/angulartest/scripts/angular.js:6749:13) at publicLinkFn (http://myhost/angulartest/scripts/angular.js:6625:30) at Anonymous function (http://myhost/angulartest/scripts/angular.js:1488:11)
app.controller('Ctrl', Ctrl);or equivalent