Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAdam White
10,571 PointsI messed code up in Angular, and can't figure it out.
I don't know enough to understand what is going on here. Wish I could look at the finished code somewhere without having to resort immediately to the forums. Thanks.
Uncaught SyntaxError: Unexpected identifier -- app.js:1
which is:
angular.module("todoListApp", [])
the complete app.js code:
angular.module("todoListApp", [])
.controller('mainCtrl', function($scope, dataService){
$scope.helloConsole = dataService.helloConsole;
$scope.learningNgChange = function() {
console.log("An input changed!");
};
$scope.todos = [
{"name": "clean the house"},
{"name": "water the dog"},
{"name": "feed the lawn"},
{"name": "pay dem bills"},
{"name": "run"},
{"name": "swim"}
]
})
.service('dateService', function() {
this.helloConsole = function() {
console.log('This is the hello console service!');
}
});
The index.html:
<!doctype html>
<html lang="en">
<head>
<title></title>
<link href='https://fonts.googleapis.com/css?family=Varela+Round' rel='stylesheet' type='text/css'>
<link href='styles/main.css' rel='stylesheet' type="text/css">
</head>
<body ng-app="todoListApp">
<h1 ng-click="helloWorld()">My TODOs</h1>
<div ng-controller="mainCtrl" class="list">
<div class="item" ng-class="{'editing-item': editing, 'edited': todo.edited}" ng-repeat="todo in todos">
<input ng-model="todo.completed" type="checkbox"/>
<label ng-hide="editing" ng-click="helloWorld()">
{{todo.name}}</label>
<input ng-change="todo.edited = true" ng-blur="editing = false;" ng-show="editing" ng-model="todo.name" class="editing-label" type="text"/>
<div class="actions">
<a href="" ng-click=" editing = !editing" >Edit</a>
<a href="" ng-click="helloConsole()">Save</a>
<a href="" class="Delete">delete</a>
</div>
</div>
{{todos}}
</div>
<script src="vendor/angular.js" type="text/javascript"></script>
<script src="scripts/app.js" type="text/javascript"></script>
</body>
</html>
2 Answers
Jason Anello
Courses Plus Student 94,610 PointsHi Adam,
You have a typo on your first argument to the service()
method. It should be dataService, not dateService
.service('dataService', function() {
Adam White
10,571 PointsOh my God. Such a silly mistake that I repeatedly missed when checking the code 5-6 times.
Thanks for your help.