1

I'm using bootstrap-material-design in my Angular app. The ripple effect works well throughout the app, though when using ng-repeat I'm losing the ripple effect.

I created an item outside the ng-repeat in the same <ul> and works fine.

Is it caused because of ng-repeat creates a new scope? If so how should I approach it correctly...?

Is there something I'm missing in my code?

<ul class="list-unstyled">
  <li class="btn" ng-repeat="data in eventsData">
    {{data.title}}
  </li>
</ul>
T J
  • 42,762
  • 13
  • 83
  • 138
Alon Rosenfeld
  • 1,392
  • 13
  • 13
  • Have you seen the incredible angular-material project? Highly recommend checking it out. It can do way more than this other framework: https://material.angularjs.org/latest/ – serraosays Dec 17 '15 at 17:00
  • @staypuftman I have, tried using it before the 1.0 release from a few days ago. I found that the documentation was lacking a bit for my knowledge, they give examples that you can learn from, but the basic layout structure is vague, and if you want to start from scratch it's not as friendly as they want it to seem – Alon Rosenfeld Dec 20 '15 at 09:59

2 Answers2

1

Looking at the documentation (very interesting project btw) I can see that you're not using the classes or tags that trigger a ripple. These are the default ones:

"withRipples": ".btn:not(.btn-link), .card-image, .navbar a:not(.withoutripple), .nav-tabs a:not(.withoutripple), .withripple"

Try adding the .withripple class, or using a button / a tag inside your li tags

David Meza
  • 3,080
  • 3
  • 16
  • 18
  • You are right! adding the ".withripple" class to the ul tag solved it. I used on my many trials, than removed it for some reason, now it works... – Alon Rosenfeld Dec 17 '15 at 15:16
1

Adding .withripple on the <ul> group will apply the ripple to the entire list, but it won't work to apply a ripple to individual elements. If you are loading a list dynamically then the repeated elements will be created after the Bootstrap Material library has initialized, so the ripple will not be applied to those elements.

To fix this, we must add the .withripple class to the repeated elements, and then initialize the library after the list has finished repeating so that the ripple can be applied. This can be done easily using Angular directives:

var app = angular.module('gradebook', []);
app.directive('repeatRipple', function() {
  return function(scope, element, attrs) {
    if (scope.$last) {
      return $.material.init();
    }
  };
});

...

<ul>
    <li ng-repeat="item in items" class="withripple" repeat-ripple>
<ul>
cjbrooks12
  • 1,368
  • 1
  • 13
  • 25