1

I am using currently materializecss tabs using [materialize]="tabs" syntax. And i am activating the tabs and dynamically rendering on the view but the active class is not applying. How to do this in angular2.

below is my code:

 <div class="row">
      <div class="col s12">
        <ul class="tabs" materialize="tabs" [materializeParams]="tabSelectionParams">
          <li class="tab col s3"><a href="#test1">Test 1</a></li>
          <li class="tab col s3"><a href="#test2">Test 2</a></li>
          <li class="tab col s3"><a href="#test3">Test 3</a></li>
          <li class="tab col s3"><a href="#test4">Test 4</a></li>
        </ul>
      </div>
      <div id="test1" class="col s12">Test 1</div>
      <div id="test2" class="col s12">Test 2</div>
      <div id="test3" class="col s12">Test 3</div>
      <div id="test4" class="col s12">Test 4</div>
    </div>

And then in my ts file I am handling the active tab using this.tabSelectionParams = ['select_tab','test2'];

This works fine once rendering the view but changing it conditionally it is not activating the tab.

Anyone has idea how to use tabs??

Toodoo
  • 8,570
  • 6
  • 35
  • 58
mpunit30
  • 381
  • 9
  • 26
  • Possible duplicate of [md-tabs Using code to goto a tab in angular 2 material design](https://stackoverflow.com/questions/42539272/md-tabs-using-code-to-goto-a-tab-in-angular-2-material-design) – Aravind Dec 15 '17 at 12:31
  • If you want to use material libraries, why not use the [official implementation of Material for Angular](https://material.angular.io/components/tabs/overview) ? I guarantee you that it will meet your needs. –  Dec 15 '17 at 12:42
  • @trichetriche: Thanks for reply but i am using materializecss not material – mpunit30 Dec 15 '17 at 13:01
  • MaterializeCSS is an implementation of Material Design. So is Angular Material. I know you're not using Material, no-one does. My question is, are you forced to use materialize, or is it personal preference ? –  Dec 15 '17 at 13:03
  • Not forced but my designer choose materializecss throughout – mpunit30 Dec 15 '17 at 13:07

0 Answers0