2

So basically I have a control on my page which when clicked needs to toggle two different elements with two different CSS classes.

I have managed to get it to toggle one of the controls, but not both.

Here is my element:

This is the element that needs to trigger both controls.

<a id="main-menu-toggle" data-toggle="collapse" data-target="#sidebar" class="hidden-xs open"><i class="fa fa-bars"></i></a>

The first element (That is working):

<div id="sidebar" class="col-lg-2 col-sm-1 collapse" style="min-height: 759px; display: block;">

</div>

Here is the second element(That i need to add):

For this element i need to trigger the CSS class 'full' when the button is clicked and then not full when its clicked again.

<div id="content" class="col-lg-10 col-sm-11 full">

</div>

I have tried to do this to the hyperlink control and it still doesn't work:

<a id="main-menu-toggle" data-toggle="collapse,full" data-target="#sidebar,#content" class="hidden-xs open"><i class="fa fa-bars"></i></a>

Does anyone know how I can get this working using AngularJS?

0

3 Answers 3

3

Try using "ng-class".

Reference:

https://stackoverflow.com/a/16529903/5052704

Hope this helps.

Sign up to request clarification or add additional context in comments.

1 Comment

I will take a look now as it seems to be the same sort of thing. Thanks :)
0

Here is a JSFiddle usign ng-class and ng-click:

<a id="main-menu-toggle" data-toggle="collapse" data-target="#sidebar" class="hidden-xs open" ng-click="clicked = (clicked) ? false : true">
   <i class="fa fa-bars"></i>click
</a>

<div id="sidebar" class="col-lg-2 col-sm-1 collapse" ng-class="{'full': clicked}" style="min-height: 759px; display: block;">
   THEDIV
 </div>

5 Comments

Nothing happens on the fiddle when i click?
Inspect the element you will see it adds and removes the full class EDIT: Added color to class to show something jsfiddle.net/michelem09/smebrtwt/1
Yeah it shows and hides the red box, but i want it to do two different things at the same time.
"when clicked needs to toggle two different elements with two different CSS classes."
Still not clear, but try this: jsfiddle.net/michelem09/smebrtwt/2 or explain better your needs.
0

You can use ngClass for class and ngStyle for style manipulation.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.