Side Menu making call with Angular!

Asked

Viewed 43 times

0

Guys, I have a menu and I need that when I click on a link it appears a content, and when I click on another link it hides the previous content and displays the new selected content, I’m using Angular 1 by particularity of the project.. I have the following code but do not know how to hide one content when another is triggered. I thank you!

<li><span class="glyphicon glyphicon-ok">&nbsp</span>
    <a ng-click="vm.link1 = true">
        Link 1
    </a>
</li> 

<section id="mainContent" class="col-md-9"
    ng-if="vm.link1">
    content 1
</section>

1 answer

1

I’ve dealt with it this way:

<li><span class="glyphicon glyphicon-ok">&nbsp</span>
    <a ng-click="vm.link = 'link1'">
        Link 1
    </a>
</li>
<li><span class="glyphicon glyphicon-ok">&nbsp</span>
    <a ng-click="vm.link = 'link2'">
        Link 2
    </a>
</li> 

<section id="mainContent" class="col-md-9"
    ng-if="vm.link == 'link1'">
    content 1
</section>
<section id="mainContent" class="col-md-9"
    ng-if="vm.link == 'link2'">
    content 2
</section>

Thanks!

  • I don’t know if ng-if accepts custom css, if you need to make effects I advise you to use the ng-show or ng-Hide documentation link: https://docs.angularjs.org/api/ng/directive/ngShow

  • Okay, thanks I’ll take a look!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.