javascript - How do I turn off active tabs in AngularJS? -


My tabs work well, but I can not understand how I click again on the same tab. As you can see I can hover over the tabs and click on them but I can not do it again to shut them down

Bonus thoughts - I also hover over them and preview the info Want to be able to!

app.js -

  App.controller ("TabController", function () {this.tab = 0; this.isSet = function (checkTab) {this. Tab return === checkTab;}; this.setTab = function (setTab) {this.tab = setTab;};});   

index.html -

  & lt; Span class = "pull-right" ng-controller = "tab controller in tab form" & gt; & Lt; Ul class = "nav nav-pills" & gt; & Lt; li ng-square = "{active: tab.isSet (1)}" & gt; & Lt; A href = "" ng-click = "tab .SetTab (1)" & gt; News & lt; / A & gt; & Lt; / Li & gt; & Lt; Li ng-square = "{active: tab.isSet (2)}" & gt; & Lt; A href = "" ng-click = "tab .settab (2)" & gt; Score & lt; / A & gt; & Lt; / Li & gt; & Lt; li ng-square = "{active: tab.isSet (3)}" & gt; & Lt; A href = "" ng-click = "tab .settab (3)" & gt; Alternative sites & lt; / A & gt; & Lt; / Li & gt; & Lt; / Ul & gt; & Lt; div ng-show = "tab.isSet (1)" & gt; {{Site.news}} & lt; / Div & gt; & Lt; div ng-show = "tab.isSet (2)" & gt; & Lt; Blockquote & gt; Governance - {{site.goverance}} | Environment - {{site.environment}} | Community - {{site.community}} & lt; / blockquote & gt; Written by CSRhub; / Div & gt; & Lt; div ng-show = "tab.isSet (3)" & gt; & Lt; Section ng-show = "site.alternatives.length" & gt; & Lt; ul class = "list-inline thumbs" & gt; {{site.alternatives}} & lt; / Ul & gt; & Lt; / Section & gt; & Lt; / Div & gt; & Lt; / Span & gt; & Lt; / Span & gt;    

I think what you want to do is: < Pre> app.controller ("TabController", function () {this.tab = 0; this.isSet = function (checkTab) {return.tab === checkTab;}; this.setTab = function (setTab) {If (setTab == this.tab) this.tab = -1 second this.tab = setTab;};});

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -