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 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,650 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,660 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.

Daniel Ram
PLUS
Daniel Ram
Courses Plus Student 14,808 Points

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.

ellie adam
ellie adam
26,376 Points

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...

ellie adam
ellie adam
26,376 Points

Hi Daniel, try $formatters and $parsers