2

How should i implement this:

4 tabs which open onclick and loads a view in to a child.

Tried with 4 ng-view tags and hiding 3 of them but it doesn't feel right. How should I display my content in the right tab?

<section id="tabs">
    <div class="tab open">
        <div ng-view></div>
    </div>
    <div class="tab">
        <div ng-view></div>
    </div>
    <div class="tab">
        <div ng-view></div>
    </div>
    <div class="tab">
        <div ng-view></div>
    </div>
</section>

2 Answers 2

1

you should use bootstrap for a tabs and ng-include for a content something like this

<!DOCTYPE html>
<html lang="en">
<head>
<!-- Le styles -->
<link href="../bootstrap/css/bootstrap.css" rel="stylesheet">
<script src="http://code.angularjs.org/1.2.12/angular.min.js"></script>
<script src="http://code.angularjs.org/1.2.12/angular-cookies.min.js"></script>
<script src="http://code.angularjs.org/1.2.12/angular-route.min.js"></script>
<script src="http://code.angularjs.org/1.2.12/angular-resource.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js"></script>
</head>

<body>

<div class="container">

<!-------->
<div id="content">
    <ul id="tabs" class="nav nav-tabs" data-tabs="tabs">
        <li class="active"><a href="#red" data-toggle="tab">Red</a></li>
        <li><a href="#orange" data-toggle="tab">Orange</a></li>
        <li><a href="#yellow" data-toggle="tab">Yellow</a></li>
    </ul>
    <div id="my-tab-content" class="tab-content">
        <div class="tab-pane active" id="red">
            <div ng-include src="'red.html'"></div>
        </div>
        <div class="tab-pane" id="orange">
             <div ng-include src="'orange.html'"></div>                
        </div>
        <div class="tab-pane" id="yellow">
            <div ng-include src="'yellow.html'"></div>
        </div>
    </div>
</div>


<script type="text/javascript">
    jQuery(document).ready(function ($) {
        $('#tabs').tab();
    });
</script>    
</div> <!-- container -->

<script type="text/javascript" src="../bootstrap/js/bootstrap.js"></script>

</body>
</html>
Sign up to request clarification or add additional context in comments.

Comments

0

Angular UI bootstrap module has all the twitter bootstrap components ported as angular modules. You should be using it instead of reinventing it (unless you cannot/dont want to use twitter bootstrap).

tldr: Try using bootstraps tabs component from angular UI bootstrap

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.