我想創建可關閉的選項卡(如chrome選項卡或firefox選項卡,每個選項卡上都有一個小「x」)。如何在UI-Bootstrap中配置現成的選項卡組件以添加此功能?如何在angularjs中創建可關閉的選項卡UI-Bootstrap
謝謝。
我想創建可關閉的選項卡(如chrome選項卡或firefox選項卡,每個選項卡上都有一個小「x」)。如何在UI-Bootstrap中配置現成的選項卡組件以添加此功能?如何在angularjs中創建可關閉的選項卡UI-Bootstrap
謝謝。
您可以在標籤標題中使用html & ng-click,例如,
<div ng-controller="mainCtrl">
<tabset>
<tab ng-repeat="t in tabs">
<tab-heading>{{t.title}} <a ng-click="removeTab($index)" href=''><i class="icon-remove"></i></a></tab-heading>
<div ng-bind-html-unsafe='t.content'></div>
</tab>
</tabset>
</div>
angular.module('myApp', ['ui.bootstrap']).controller("mainCtrl", function ($scope) {
$scope.tabs = [{
title: "one",
content: '<h1>tab one</h1>'
}, {
title: "two",
content: '<h1>tab two</h1>'
}, {
title: "three",
content: '<h1>tab three</h1>'
}];
$scope.removeTab = function (index) {
$scope.tabs.splice(index, 1);
};
});
的jsfiddle:http://jsfiddle.net/alfrescian/ZE9cE/
謝謝!正是我想要的。 – janetsmith
不確定這是否爲有效的HTML,因爲該標籤將嵌套在由tab指令生成的另一個標籤下。 – kentor
相信這是一個有點太廣,你也應該表現出你和具體(鏈接/代碼)的工作是什麼,告訴你已經嘗試了什麼。 – shaunhusain
我正在嘗試查找是否有用於此的現成庫或任何此配置。在搜索現有資料之前跳入編碼並不是一個好習慣。 – janetsmith
確實如此,但是如果不自己研究,也不是好的做法。 http://stackoverflow.com/questions/how-to-ask注意第一步是研究。我希望你們能夠在我開始構建太陽下的所有東西之前先看看,但是SO是從A到B的引導式幫助。您是否嘗試將AngularUI作爲起點或基於Angular構建的其他代碼?你有選項卡代碼,並不能找出關閉部分?拖放鏈接可以讓人們更容易地給出答案,而您更有可能獲得答案。 – shaunhusain