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 Extending Inputs Attaching a Datepicker

Brandon Brown
PLUS
Brandon Brown
Courses Plus Student 7,737 Points

Having trouble with two fill in the blank quiz questions on Angular JS Stage 5 Extending Inputs.

I cant find any definitions in the video transcript. I have even entered things like $render, $apply, $digest, $viewValue and get no luck...

Going first from model to view, and second from view to model, what are the two arrays NgModelController provides for transforming data?

This method on NgModelController is what we call when data has changed via the view (ie. our plugin) and we want to update the value attached to the model:

6 Answers

Matthew Goodrich
Matthew Goodrich
1,989 Points

The answer accepts $formatters and $parsers in that order. $formatters (model to view) and $parsers (view to model) .

Chris Shaw
Chris Shaw
26,676 Points

Hi Brandon,

This question is tricky but does offer a clue which was talked about in the video, the clue by the way is transforming. In AngularJS there's two types of transform arrays:

  • the first is $parsers
  • the second is $formatters

AngularJS will always execute $parsers before $formatters hence that's the answer the question is looking for, if that seems confusing in any way don't worry as you can find much more information at the following link.

AngularJS ngModel.NgModelController

Brandon Brown
Brandon Brown
Courses Plus Student 7,737 Points

I tried those and the question says incorrect. Also what about the other question?

Juan Francisco Andrade Álvarez
Juan Francisco Andrade Álvarez
23,997 Points

The answer for the other question is $setViewValue. I tried $setViewValue() but the quiz marked as incorrect. For the other question, in fact the answer is $parsers and $formatters, but the quiz is again wrong and marks it as invalid.

Please check this TreeHouse.

Sean T. Unwin
Sean T. Unwin
28,690 Points

The link to AngularJS ngModel.NgModelController should be in the teacher's notes in order to help find the answer to this question as it not obvious since Alex does not mention these two terms ($formatters and $parsers) in the video.

edit: I notice Alex talks about this briefly in the first video in this section - A Deeper Dive Into ng-model. The link to the docs should still be in the teacher's notes, I believe.

But you gotta read the question. Going from Model to View is $formatters and going from View To Model is $parsers. It was intentionally done to reinforce the concept I think.

Seth Scoville
Seth Scoville
2,496 Points

I don't think that was even discussed in the preceding video, was it? This course has been a complete mess.

I had same problem but I passed by switching them around.

$formatters and $parsers

Gavin Engel
Gavin Engel
542 Points

I believe he mentioned them as first '$parsers' then '$formatters', so I was doing it in that order. It would be nice if the answer validation accepts any order...

Hi Daniel, try $formatters and $parsers