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 Looking at ng-model: Part 2

Damien Watson
Damien Watson
27,419 Points

'user.bio' data not displaying in the page.

This may be similar to the problem another user had, but the answer was unresolved due to lack of content: Connect hallo directive.

The main line copied from the video creates a 'div' with class 'textarea' and links the 'ng-model' as below. This should be populated from the datasource. I'm pretty sure its along the same lines as the video, maybe I have a typo somewhere?

Appreciate the help.

<body ng-app="MyApp" ng-controller="stageTwoCtrl">
  <div id="container">
    <div id="content">
      Hello {{user.name}}!
      <div class="textarea" ng-model="user.bio" hallo></div>
    <div id="debug">
      <pre>{{user | json}}</pre>
    <div class="clearFix"></div>

  <script src="https://code.jquery.com/jquery-1.11.0.min.js" type="text/javascript"></script>
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.25/angular.min.js" type="text/javascript"></script>
  <script src="js/hallo.js" type="text/javascript"></script>
  <script src="js/app.js" type="text/javascript"></script>
angular.module("MyApp", []).
  controller("stageTwoCtrl", function($scope) {
    $scope.user = {
      "name": "world",
      "bio": "Roof party pop-up messenger bag Godard, Wes Anderson Carles pork belly Marfa selfies butcher. 3 wolf moon salvia listicle, normcore Marfa Carles gentrify meditation."
  .directive('hallo', function() {
    return {
      require: 'ngModel',
      link: function($scope, $element, $attrs, ngModelCtrl) {
          plugins: {
            'halloformat': {},
            'halloblock': {},
            'hallojustify': {},
            'hallolists': {},
            'halloreundo': {}

        ngModelCtrl.$render = function() {
          var contents = ngModelCtrl.$viewValue;
          $element.hallo('setContents', contents);