AngularJS add new tabs to boostrap tab list - angularjs

I try to implement a tabs nav bar in my app. I use Bootstrap3 and follow this example Boostrap Tabs and Pills.
I have one tab (#home) that is presented every Time. The other tabs i want to generate when i click on addInput() function. I.e tab1, tab2, tab3.
I dont know exactly how to get the combination togther. How can i create a list element with href="#menu1" for the navbar and fitting id="menu1" for the content inside tab.
Here is my example CodePen.io
<div ng-app="myApp" ng-controller="myCtrl">
<form>
<div class="form-group">
<label for="txtDevice" class="control-label">Form Field 1</label>
<input type="text" class="form-control" ng-model="info.name" id="txtDevice">
</div>
<div class="form-group">
<label for="txtIP" class="control-label">Form Field 2</label>
<input type="text" class="form-control" ng-model="info.ip" id="txtIP">
</div>
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#home">Home</a></li>
</ul>
<div class="form-group tab-content">
<div id="home" class="tab-pane fade in active">
<h4>Home</h4>
<p>content</p>
</div>
<div ng-repeat="site in info.sites track by $index">
<h4>tab {{$index +1}}</h4>
<p>content</p>
</div>
</div>
</form>
<button ng-click="addInput()">+add more inputs</button>
{{info | json}}
<hr>
tags = {{tags | json}}
</div>

There were about four things wrong with your pen, that I have fixed here (http://codepen.io/anon/pen/eBRwev?editors=1010)
Your tabs navigation did not include an ng-repeat for the tab headings
<ul id="myTabs" class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#home">Home</a></li>
<li ng-repeat="site in info.sites track by $index" class="tab-pane fade in">
<a data-toggle="tab" href="#tab-{{$index}}" >Tab #{{$index}}</a>
</li>
</ul>
You forgot to include jQuery and Bootstrap JS libraries which are required to use the bootstrap tabs.
You have to call the following snippet of JS to activate the bootstrap click handling on the tabs
$('#myTabs a').click(function (e) {
e.preventDefault();
$(this).tab('show');
});

You're looking something like this?
id="{{ 'menu' + $index }}"

Related

angularjs disable does not work

Why doesnt the ng-disabled work in my code?
I have created a plunker.. any suggestions?
https://plnkr.co/edit/j2LnhLxBe5gHPITMqzUJ?p=preview
<ul ng-repeat="permission in permissions" ng-click="permission.assigned=!permission.assigned">
<a class="list-group-item" ng-class="{active: permission.assigned, disable: permission.name=='default'}">
<div class="row">
<div class="col-md-3">
<input type=checkbox aria-label="checkbox" ng-model="permission.assigned" ng-click="$event.stopPropagation()">
</div>
<div class="col-md-4">{{ permission.name }}</div>
<div class="col-md-6">{{ permission.description }}</div>
</div>
</a>
</ul>
Add the following to your input element - ng-disabled="permission.name === 'default'".

Selenium WebDriver -cannot switch focus to modal dialog window

screenshotThe scenario is that I am trying to fire sendkeys into a modal dialog box, but webdriver is unable to switch focus onto dialog box. I've tried variety of wait conditions and switch conditions without being successful
Here is the HTML code
New
<div class="row">
<ul class="nav nav-tabs">
<li role="presentation" class="active"><a data-toggle="tab" href="#ModalAddCampaignsSearchTab">Search</a></li>
<li role="presentation"><a data-toggle="tab" href="#ModalAddCampaignsToAddTab">New ({{DealerFactory.Campaign.NumberOfCampaignsToAdd()}})</a></li>
</ul>
<div class="tab-content">
<div id="ModalAddCampaignsSearchTab" class="tab-pane fade in active">
<br/>
<div class="col-lg-12">
<label for="Select_A_Campaign">Select A Campaign</label>
<div class="form-group">
<div class="input-group">
<div class="input-group-addon">
<i class="fa fa-search" id="icoSearch"></i>
<i class="fa fa-spinner fa-pulse" id="icoSearching" style="display: none;"></i>
</div>
<input class="form-control" id="txtCampaignSearch" name="txtCampaignSearch" ng-change="findDealersToAdd()" ng-model="DealerFactory.Campaign.searchCampaigns.searchTerm" placeholder="Search" type="text" value="" />
</div>
</div>
<div id="divCampaignSearchModalResults" class="well" ng-show="DealerFactory.Campaign.searchCampaigns.campaigns.length>0" >
<div class="row">
<div class="col-lg-12 text-right">
<p>
Campaigns: {{DealerFactory.Campaign.searchCampaigns.campaigns.length}}
</p>
</div>
</div>
<div class="row">
<div class="col-lg-12">
Any help/corrections/suggestions are hugely appreciated
The Element I am trying to target is id='txtCampaignSearch'
I am using visual studio (IDE) & webdriver
Bootstrap is creating the modal with javascript and css, it is not creating a new window that you would have to switch between, as your question implies.
The real problem is that using "input-group-addon" blocks the WebDriver from accessing the input field for some reason, a problem I have run into as well.
Waiting for the modal animation to finish is all you should have to do before clearing and sending keys to txtCampaignSearch.
I had a similar problem with input-group-addon and solved it using javascript. Try something like this:
JavascriptExecutor js = (JavascriptExecutor)driver;
// later on...
js.executeScript("document.getElementById('txtCampaignSearch').value = 'something';");

ng-show and ng-hide not working

I am new to Angularjs. Following is the scenario I am trying to achieve:
Scenario: I need to hide the search bar and the table when am in my "card.html" page which is called by using the function redirectsearchcardURL. Later when I click on 'Home', again the search and table should be shown.
I am using ng-hide to hide the search bar and table but again when i click on home, the search and table is not visible to me.
Below is my code.
home.html file.
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-sidebar-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="active">Home<span style="font-size:16px;" class="pull-right hidden-xs showopacity glyphicon glyphicon-home"></span></li>
</ul>
</div>
</div>
</nav>
<center class="main">
<div class="container" ng-controller="card-set-controller" ng-init="getAllSets()">
<form ng-hide ="hideVar" action="#" method="get" style="margin-top:75px; margin-bottom:75px">
<div class="col-md-6 input-group has-feedback">
<input class="form-control" id="system-search" placeholder="Search Flashcard Sets">
<i class="glyphicon glyphicon-search form-control-feedback"></i>
</div>
</form>
<table ng-hide ="hideVar" class="table table-hover table-responsive table-list-search">
<tbody>
<tr class="active" ng-repeat="set in sets">
<td>{{set.Name}}</td>
</tr>
</tbody>
</table>
</div>
</center>
My controller code where I am setting my "hideVar" is:
$scope.redirectSearchCardUrl = function(setIdNum, name) {
var url = "/card/"+setIdNum+ "/"+name;
$scope.hideVar = true;
$location.path(url);
}
Are you ever setting hideVar back to false? You could do
<li class="active">Home</li>

filter incoming input value and show or hide divs in angular

I have a trivial problem out there. I need to make a filter search on the page with input . I'm using a boonex platform. I need to insert the input tag and it should hide or show the DIV blocks wich depends of value of input. this is the a code of my HTML page:
<ul id="navtabsidebar" class="nav nav-justified nav-tabs">
<bx_repeat:tabs_name>
<li class="__status__">
<a data-toggle="tab" href="#__tab_name__"><i class="fa fa-__icon__"></i></a>
</li>
</bx_repeat:tabs_name>
</ul>
<div class="tab-content" ng-app>
<input type="text" ng-model="filter">
<bx_repeat:tabs>
<div id="__tab_name__" class="tab-pane __status__">
<bx_repeat:users_list>
<div class="memberUser">
__user_avatar__
__chat__
</div>
</bx_repeat:users_list>
</div>
</bx_repeat:tabs>
</div>
Does someone how any ideas? Thanks guys

select2 not working inside bootstrap tab

I'm using bootstrap tab,I have two tabs(tab1,tab2), both tab contains a select2 dropdown. The first one works fine but the select2 dropdown in tab2 is not working.Here is my code.
HTML
<div ng-controller="myctrl">
<ul class="nav nav-tabs nav-justified" role="tablist">
<li class="active"><a data-toggle="tab" data-target="#tab1">Tab1</a></li>
<li><a data-toggle="tab" data-target="#tab2">Tab2</a></li>
</ul>
<div class="tab-content">
<div id="tab1" class="tab-pane fade in active">
<input type="hidden" id="test1"/>
</div>
<div id="tab2" class="tab-pane fade in active">
<input type="hidden" id="test2"/>
</div>
</div>
</div>
JS
myapp.controller('myctrl',function(){
var test1 =$('#test1');
$(test1).select2({
data:[{'id':1,'text':'None'},{'id':2,'text':'High'},{'id':3,'text':'Medium'},{'id':4,'text':'Low'}],
multiple: false,
});
var test2 =$('#test2');
$(test2).select2({
data:[{'id':1,'text':'None'},{'id':2,'text':'High'},{'id':3,'text':'Medium'},{'id':4,'text':'Low'}],
multiple: false,
});
})
please help me.
you shouldn't combine jquery and angularjs in this way.
Check out Bootstrap UI directives: http://angular-ui.github.io/bootstrap/#/tabs

Resources