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 trialDavid Karlsson
4,180 PointsIt says that console.log should be called within my render function, which it is.
I still have trouble understanding what exactly I'm supposed to log to the console. This is very unclear to me and after rewatching the video a couple of times, it's still not very clear. Sorry for the inconvenience.
angular.module('myApp', [])
.controller('myController', function($scope) {
$scope.user = {
name: 'Alex'
};
})
.directive('myDirective', function () {
return {
require: 'ngModel',
priority: 1,
link: function ($scope, $element, $attrs, ngModelCtrl) {
// YOUR CODE HERE
ngModelCtrl.$render = function(){
console.log($viewValue);
}
}
}
});
<!DOCTYPE html>
<html ng-app="myApp">
<head>
<title>Angular.js</title>
<script src="js/angular.js"></script>
<script src="app.js"></script>
</head>
<body ng-controller="myController">
<p>Hello {{user.name}}</p>
<input type="text" ng-model="user.name" />
<div my-directive ng-model="user.name"></div>
</body>
</html>
3 Answers
Riley Hilliard
Courses Plus Student 17,771 PointsYou're super close. $viewValue is not a standalone variable. It is attached to the ngModelCtrl. So in referencing it, use dot notation to access that property from ngModelCtrl. Hint: console.log(ngModelCtrl.____________ )
Jason Lewis
984 PointsThis problem makes no sense and is very confusing of what is needed to complete the problem. Thank you for asking this question and thank you Riley for the hint!
David Karlsson
4,180 PointsI'm sorry, do you mean I should have understood it without any problems? I guess I must have missed something in that case, sorry.
Evan Turner
294 PointsThese hints are not helpful and are running my code in circles of deleting and readding.
David Karlsson
4,180 PointsDavid Karlsson
4,180 PointsThanks, that worked, sadly I have no idea how I was supposed to get to that conclusion. I'll keep doing the course and see if things start to clear up.