2
Good guys I’m starting to study Angularjs, and in my application I wanted to do something similar to the following.
I have a dropdown menu and I also have some tabs that I created manually. By clicking on a menu item I wanted to make this tab receive the view but I’m not getting it. The most I did was by clicking on the change the corresponding content using the routes.
follows down the code I’ve only made of html assuming I have a part of routes already ready.
<div class="btn-group">
<button type="button" class="btn btn-primary" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Action <span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li><a href="#create">Action</a></li>
<li><a href="#list">Another action</a></li>
<li><a href="#list">Something else here</a></li>
</ul>
</div>
<div class="container" ng-init="tab=1">
<ul class="tabs-nav">
<li><a ng-click="tab=1" href="#edit" ng-class="{'active' : tab==1}">Aba 1</a></li>
<li><a ng-click="tab=2" href="#list" ng-class="{'active' : tab==2}">Aba 2</a></li>
<li><a ng-click="tab=3" href="#create" ng-class="{'active' : tab==3}">Aba 2</a></li>
</ul>
<div class="tabs-container">
<div class="tab-content" ng-show="tab == 1">
<div ui-view="main"></div>
</div>
<div class="tab-content" ng-show="tab == 2">
<div ui-view="main"></div>
</div>
<div class="tab-content" ng-show="tab == 3">
<div ui-view="main"></div>
</div>
</div>
</div>
It’s a basic example more what I’m doing is the following, I have a few tabs and in these tabs when I click on them they carry the content up to ai ok. However what I wanted is to click on the menu link one of the tabs received the view that I would configure. As I mentioned earlier I am using the routes to change by clicking on the tabs just wanted to do by the menu I am not able to link the menu with the tabs. If anyone has a solution for that thank you.
Which route system you are using?
– celsomtrindade
I’m using the ui-router app.config(Function ($stateProvider, $urlRouterProvider) ai has the following "States", list create and Edit with the corresponding controllers and views.
– Davi Pereira
You can’t put the template directly into html? or an ng-include?
– celsomtrindade
Have you tried that?
/#edit
,/#create
,/#list
– Ivan Ferrer
@Celsomtrindade was what I thought to put this question I am not able to reference the menu button with the tab. By clicking the la menu item in my tab 1 for example the view to be called. Ivanferrer is exactly what I’m doing today, but what I’m doing is in the tabs by clicking on the tab itself opens the route /#Edit and so on. I wanted to click on the menu and in one of the tabs appear the view of a form. The question is how to link the menu item to a tab.
– Davi Pereira
<a href="/#edit">Editar</a>
? Actually you have to put the bar as soon as it enters the page. your index always has to have a bar/ The problem is that the angular route makes use of the wire, and confuses a little with note on the same page.– Ivan Ferrer
@Ivanferrer this, however when clicking on one of the la items in the dropdown menu appear in one of the view tabs that I configure in the routes.
– Davi Pereira
Your url has to look something like this: www.site.com.br/home/#/Edit
– Ivan Ferrer
I made with both modes for you @Davipereira see if any meets your need.
– celsomtrindade
I don’t know what exactly the problem you’re having, but here in a system I did, it works normal...
– Ivan Ferrer
@ivanFerrer I will be and soon post the result grateful for the help. I will update soon.
– Davi Pereira