我有以下格式的角度引导标签。(请参阅缩孔器)
选择选项卡时,应该触发选择功能。但是奇怪的是,当页面加载时,第一个选项卡的选择功能被触发。(在“打印”选项卡上选择了“动态标题1”。)
"http://plnkr.co/edit/vyOOhCdIl7s1Wvou7Dr9?p=preview"
angular.module('ui.bootstrap.demo', ['ui.bootstrap']);
angular.module('ui.bootstrap.demo').controller('TabsDemoCtrl', function ($scope) {
$scope.tabs = [
{ title:'Dynamic Title 1', content:'Dynamic content 1' },
{ title:'Dynamic Title 2', content:'Dynamic content 2' },
{ title:'Dynamic Title 3', content:'Dynamic content 3' }
];
$scope.tabSelect = function(title){
console.log("tab selected "+title);
};
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<!doctype html>
<html ng-app="ui.bootstrap.demo">
<head>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.13/angular.js"></script>
<script src="//angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.13.0.js"></script>
<script src="example.js"></script>
<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div ng-controller="TabsDemoCtrl">
<tabset>
<tab ng-repeat="tab in tabs" heading="{{tab.title}}" active="tab.active" disable="tab.disabled" select="tabSelect(tab.title)">
{{tab.content}}
</tab>
</tabset>
</div>
</body>
</html>
将您的选择更改为ng-click,如下所示:
<tab ng-repeat="tab in tabs" heading="{{tab.title}}" active="tab.active" ng-click="tabSelect(tab.title)">
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句