morgs32
morgs32

Reputation: 1459

Apply classes conditionally in ANGULAR - using controller function WITH PARAMETERS

This is what I'm trying to do:

<div class="row-fluid" ng-repeat="subtopic in topic.Subtopics">
  <div class="row_divider"></div>
  <div class="row_padding">
    <span class="subtopic_level">{{subtopic.Name}}</span>
  </div>
  <div class="row-fluid" ng-repeat="subsubtopic in subtopic.Subsubtopics">
    <div class="row_divider" ng-hide="subsubtopic.Name = subtopic.Name"></div>
    <div class="row_padding" ng-hide="subsubtopic.Name = subtopic.Name">
      <span class="subsubtopic_level">{{subsubtopic.Name}}</span>
    </div>
    <div ng-class="row-fluid: true, flat: flatTopicBranch(subsubtopic.Name=subtopic.Name)" ng-repeat="lesson in subsubtopic.Lessons">
      <div class="row_divider"></div>
      <div class="row_padding">
        <span class="lesson_level">{{lesson.Name}}</span>
      </div>
    </div>
  </div>
</div>

Here's the function in my controller:

controllers.controller('YourSigmaCtrl', function ($scope, $http) {
...
  $scope.flatTopicBranch = function (subsubtopic, subtopic) {
    return subsubtopic === subtopic;
  };
...

It's showing up in the html unchanged. Unaffected. Uneffected. Any ideas?? Is flatTopicBranch a problem because I'm deeper into the scope when I call it??

Thanks!

Upvotes: 0

Views: 127

Answers (1)

callmekatootie
callmekatootie

Reputation: 11228

<div ng-class="row-fluid: true,
flat: flatTopicBranch(subsubtopic.Name=subtopic.Name)"
ng-repeat="lesson in subsubtopic.Lessons">

This is the code which contains the call to the flatTopicBranc() function. This function accepts two parameters. As you can see, when you are calling this function, you seem to be passing only one parameter: flat: flatTopicBranch(subsubtopic.Name=subtopic.Name). Are you looking to pass two parameters?

In other words, maybe you need to change the call to flat: flatTopicBranch(subsubtopic.Name, subtopic.Name) - passing two parameters instead of one (you are using the equality operator, I suspect you wanted to pass two parameters separated by a comma instead of one single operator.

Upvotes: 1

Related Questions