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

Ryan Hellerud
Ryan Hellerud
3,635 Points

angular.js with zurb foundation reveal modal?

Trying to use angular so that when an anchor is clicked will display relevant data in a reveal modal.

First, I've put everything on one page, so that I can have the foundation modal reveal try to work. The reveal modal is dropping down but its obviously not set up right. The live temp domain can be viewed at:

http://new.omegadesignla.com/courses/classlist.php

Maybe I should use the angular UI one instead?

Here's what I have so far:

<div class="row">
    <div class="small-12 columns">
      <div class="row">
          <div class="small-6 columns"><h1>Full Course Search</h1>
       <div>
      <label>Filter:</label>
      <input type="text" ng-model="searchTxt" placeholder="Enter a class here">
      <hr></div>
      </div>

<!--      <h1>Test {{searchTxt}}!</h1>-->
    </div>
 <table ng-controller="oflClassCtrl">
  <thead>
    <tr>
      <th>Course Title(Apex/Isis)</th>
    </tr>
  </thead>
  <tbody>
    <tr ng-repeat = "c in classes | filter:searchTxt">
        <td><td><a href="#" data-reveal-id="myModal" ng-click="setClass($index)">{{c.class}}</a></td></td>
    </tr>
  </tbody>

</table>
    </div>
</div>

<div id="myModal" class="reveal-modal" data-reveal>
  <div class="accordion accorborder" ng-controller="oflClassCtrl" data-accordion>


        <div class="accordion-navigation">
            <h3>{{c.class}} </h3>
            <div id="p1" class="content">
               <div class="row">
                   <div class="small-6 columns">
                        <h6>Code:</h6>{{c.code}}
                        <h6>Offerings:</h6>{{c.offerings}}
                   </div>
                   <div class="small-6 columns">

                       <h6>Course Materials:</h6>
                       <ul>
                           <li>
                               <a href="{{c.syl}}">Syllabus</a>
                           </li>
                           <li>
                               <a href="{{c.cc}}">Course Contract</a>
                           </li>
                           <li>
                               <a href="{{c.wb}}">White Board</a>
                           </li>
                       </ul>
                   </div>
               </div> 
                <p>
                {{c.para}}
                </p>
<!--                Panels-->
        <dl class="tabs" data-tab>
        <dd class="active"><a href="#p1a">Study Sheets</a></dd>
        <dd><a href="#p1b">Study Sheets Answer Keys</a></dd>
        <dd><a href="#p1c">Graded Assignments</a></dd>
        <dd><a href="#p1d">Graded Assignment Answer Keys</a></dd>
      </dl>
      <div class="tabs-content">
        <div class="content active" id="p1a">
              <ul class="ss">
              <li><a href="{{c.ssu1}}">Study Sheet Unit One</a></li>
              <li><a href="{{c.ssu2}}">Study Sheet Unit Two</a></li>
              <li><a href="{{c.ssu3}}">Study Sheet Unit Three</a></li>
              <li><a href="{{c.ssu4}}">Study Sheet Unit Four</a></li>
              <li><a href="{{c.ssu5}}">Study Sheet Unit Five</a></li>

              </ul>
        </div>
        <div class="content" id="p1b">
          <ul class="ssa">
              <li> 


...................ectt...........

</li>
              </ul>
        </div>
      </div>       
            </div>  
        </div>
        </div>
  <a class="close-reveal-modal">&#215;</a>
</div>

the controller:

var oflApp = angular.module('oflApp', []);

oflApp.controller('oflClassCtrl', function ($scope) {


  $scope.classes = [
{"class": "ENGLISH I: INTRO TO LITERATURE AND COMPOSITION Sem 2", "href": "../courses/english.php#p1"},
{"class": "ENGLISH II: CRITICAL READING AND EFFECTIVE WRITING Sem 1"},
{"class": "ENGLISH II: CRITICAL READING AND EFFECTIVE WRITING Sem 2" },
{"class": "ENGLISH III: AMERICAN LITERATURE Sem 1" },
{"class": "ENGLISH III: AMERICAN LITERATURE Sem 2"},
{"class": "ENGLISH IV: BRITISH AND WORLD LITERATURE Sem 1"},
{"class": "ENGLISH IV: BRITISH AND WORLD LITERATURE Sem 2"},
{"class": "AP ENGLISH LANGUAGE AND COMPOSITION Sem 1"},
{"class": "AP ENGLISH LANGUAGE AND COMPOSITION Sem 2"},
{"class": "ENGLISH I: INTRO TO LIT & COMP LIT ADVANTAGE Sem 1"},
{"class": "ENGLISH I: INTRO TO LIT & COMP LIT ADVANTAGE Sem 2"},
{"class": "ENGLISH II: CRIT READING & EFFECTIVE WRITING LIT ADV Sem 1"},
{"class": "ENGLISH II: CRIT READING & EFFECTIVE WRITING LIT ADV Sem 2"},
{"class": "AP ENGLISH LITERATURE AND COMPOSITION Sem 1"},
{"class": "AP ENGLISH LITERATURE AND COMPOSITION Sem 2"},
{"class": "MULTICULTURAL STUDIES ALGEBRA 1 SEM 1"},
...ect....

  ];

$scope.setClass = function(index) {
    $scope.selectedClass = $scope.classes[index];
        };    

});

1 Answer

Chris Shaw
Chris Shaw
26,676 Points

Hi Ryan,

I noticed in your markup you have calls in your modal such as {{c.class}} but in your JavaScript your object points to $scope.selectedClass instead of $scope.c which is what your markup is pointing to, change either of those to match and it should work.

Ryan Hellerud
Ryan Hellerud
3,635 Points

Hmm thanks, thats something i overlooked, probably more errors or maybe i need to use http://pineconellc.github.io/angular-foundation/ ? because i changed $scope.c to $scope.selectedClass , but it didn't work yet. It just loads a blank reveal.