Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript

Michael Paccione
Michael Paccione
9,017 Points

Two Way Data Binding AngularJS Challenge Task 1 of 2

Hi there,

I'm just starting to learn angular and the first challenge is to output Hello follow by the value stored in user.name within a paragraph tag. Thought this would work but it doesn't...

<!DOCTYPE html>
<html ng-app="myApp">
<head>
  <title>Angular.js</title>
</head>
<body>
<p ng-model="user.name">Hello {{user.name}}</p>
  <script src="js/angular.js"></script>
  <script src="app.js"></script>

</body>
</html>
var myApp = angular.module('myApp',[]);
.controller('myFirstController', function ($scope) {
  $scope.user = {
    name: "Michael"
  };
});

1 Answer

Michael Paccione
Michael Paccione
9,017 Points

I just passed this but now...It makes more sense after seeing challenge task 2. Essentially this wanted me to simply link an input to a paragraph output. Fair enough I suppose you don't need any different change to the JS for that. I was imagining it pulling a predefined object value when I created the question.

<!DOCTYPE html>
<html ng-app="myApp">
<head>
  <title>Angular.js</title>
</head>
<body>
  <p ng-model='user.name'>Hello {{user.name}}</p>
  <script src="js/angular.js"></script>
  <script src="app.js"></script>

</body>
</html>
var myApp = angular.module('myApp',[]);