0

I am new to Angularjs and i am starting to play with tabs in angularJS. The example I picked up directly from AngularJS-UI-Bootstrap webpage. So my end goal is to add dynamic html content inside tabs rather then simple text. How should i approach ? my html looks like this

 <div ng-controller="chatsController">
   <h1> Anguchat </h1>
   <hr/>
   <uib-tabset active="active">
       <uib-tab index="$index + 1" ng-repeat="tab in tabs" heading="{{tab.title}}" disable="tab.disabled">
          {{tab.content}}
       </uib-tab>
   </uib-tabset>
</div>

And my angular controller looks like this.

angular.module('anguchat', ['ui.bootstrap']);
angular.module('anguchat').controller('chatsController', function ($scope, $window) {

  $scope.tabs = [
    { title:'Room1', content:'I want to add html here' },
    { title:'Room2', content:'Dynamic content 2' }
  ];

});

1 Answer 1

1

Can use ng-include to add html template to the DOM

<uib-tabset active="active">
   <uib-tab index="$index + 1" ng-repeat="tab in tabs" heading="{{tab.title}}" disable="tab.disabled">
      <div ng-include="tab.content">
      </div>
   </uib-tab>
</uib-tabset>


$scope.tabs = [
    { title:'Room1', content:'template1.html' },
    { title:'Room2', content:'template2.html' }
];

Demo

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

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.