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 An Introduction to Two-Way Data Binding ng-model

unresolved syntax error in simple angular app.

Hi, I keep receiving an error and I'm not entirely sure why.

index.html
<!DOCTYPE html>
<html ng-app="myApp">
<head>
  <title>Angular.js</title>
</head>
<body>

  <div>
    <p>Hello {{user.name}}</p> 
  </div>  

  <script src="js/angular.js"></script>
  <script src="app.js"></script>

</body>

</html>
app.js
var myApp = angular.module('myApp',[ 
            $scope.user {
                           "name":"Elaine"
                           }
]);

1 Answer

Chris Shaw
Chris Shaw
26,676 Points

Hi Elaine,

I believe you're misreading what the task is asking, just to reiterate below is the task.

In index.html, write the HTML to output 'Hello ' followed by the value stored in user.name within a paragraph tag.

What this is asking for is for you to add a p tag to the HTML which contains the world Hello followed by a space then request the value for user.name which we can get by using the curly {} brackets.

<p>Hello {{user.name}}</p>
What about your JS code?

You can remove that as the task isn't requesting you write any JavaScript, in saying that it's also invalid because you haven't done the following.

  1. You have started using the array notation but haven't complete it, you're missing your $scope and function declarations
  2. You don't have an equals sign after $scope.user

If the challenge was asking for this you would want to do something like the below.

var myApp = angular.module('myApp', ['$scope', function($scope) {
    $scope.user = {
        name: "Elaine"
    }
}]);

Happy coding!