1

I have successfully implemented tabs in a modal with the Angular directives for TB. I have been trying to figure out from the documentation how to make certain things happen when a tab is clicked. No success yet.

View

<tabset>
        <tab ng-repeat="tab in tabs" active="tab.active" heading="{{tab.title}}" disabled="tab.disabled" >
            <div ng-include="tab.content"></div>
        </tab>
    </tabs>

Controller

$scope.tabs = [
        { title:"Home", content:"/beta/application/views/images/uploader/create.html", active: true },
        { title:"Upload", content:"/beta/application/views/images/uploader/upload.html"},
        { title:"Edit", content:"/beta/application/views/images/uploader/edit.html"}
    ];

There is a ng-click="select()", leaving me to think I could call the following.

$scope.select = function () {
    console.log('testing');
};

Obviously I am wrong.

Thanks

1 Answer 1

3

I think you're talking about the AngularUI tabs and I think you are talking about the select attribute on the directive.

If you put the select="scopeMethod()" on the tab directive, and define the controller method like so:

$scope.scopeMethod = function(){
  //Do something meaningful
  alert("You clicked this tab");
}

the method will fire when you click on that tab.

This should also work for tabs that are created within an ng-repeat. See this plunkr

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

3 Comments

your assumptions are correct. Using the ng-repeat, do you know what the best option is for firing a method for a particular tab? -- thanks
Apparently, I was wrong. This should also work on tabs within an ng-repeat. See my edit and link to the plunker.
thanks man, solid answer and clears up some other issues as well. Thanks

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.