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 trial

JavaScript AngularJS Basics (1.x) Controllers and Scope Creating a Controller

Amanda Olczak
Amanda Olczak
4,124 Points

Getting the following error: angular.js:12416Error: [$parse:syntax] http://errors.angularjs.org/1.4.5/$parse/syntax?p0=%

from the angular.js file:
if (hasApply) { return function() { var args = []; forEach(arguments, function(arg) { args.push(formatError(arg)); }); return logFn.apply(console, args); }; } error is showing on the last line of text.

I've gone over my code, shown below, and I don't think that's the problem

// javascript - app.js// angular.module("todoListApp", []) .controller("mainCtrl", function($scope) { $scope.helloWorld = function() { console.log("Hello there! There is the helloWorld controller function, in the mainCtrl"); }; });

//html - 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>My ToDos</h1> <div ng-controller="mainCtrl" class="list"> <input type="checkbox" /> <lable class="editing-lable">A Sample To Do</lable> <input type="text" class="editing-lable" /> <div class="actions"> <a href="">edit</a> <a href="" ng-click="<helloWorld()">save</a> <a href="" class="delete">delete</a> </div> </div>

<script src="vendor/angular.js" type="text/javascript"></script>
<script src="scripts/app.js" type="text/javascript"></script>

</body>

</html>

Any ideas?

jag
jag
18,266 Points

Just to clean it up.

Angularjs

if (hasApply) {
    return function() {
        var args = [];
        forEach(arguments, function(arg) {
            args.push(formatError(arg));
        });
        return logFn.apply(console, args);
    };
}

app.js

angular.module("todoListApp", []).controller("mainCtrl", function($scope) {
    $scope.helloWorld = function() {
        console.log(
            "Hello there! There is the helloWorld controller function, in the mainCtrl"
        );
    };
});

index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <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>My ToDos</h1>
    <div class="list">
        <input type="checkbox"> A Sample To Do <input class="editing-lable" type="text">
        <div class="actions">
            <a href="">edit</a>
            <a href="">save</a>
            <a class="delete" href="">delete</a>
        </div>
    </div>
    <script src="vendor/angular.js" type="text/javascript">
    </script> 
    <script src="scripts/app.js" type="text/javascript">
    </script>
</body>
</html>

1 Answer

jag
jag
18,266 Points

<a href="" ng-click="<helloWorld()">save</a>

There is a < inside the ng-click attr.

Amanda Olczak
Amanda Olczak
4,124 Points

Thank you! Issue fixed!

Amanda Olczak
Amanda Olczak
4,124 Points

Also, how did you re-post the code in those nice boxes? When I posted my question I did not see how to do that.

jag
jag
18,266 Points

You can do multiple code boxes you can see the markdown cheatsheet. The way you do it is with three backticks (`) followed by html, js, css or other codes then closed by another three back ticks.

```[type of code]


`.`` Without the .


<!--  Like so -->

```html


`.``