如何使用angular tab指令中的href链接通过路由转到视图。不知何故,我认为你必须将根范围添加到指令中。
appTreeDirectives.directive('tabs',function(){ 返回{ 限制:'E', transclude:true, 范围: {}, controller:function($ scope,$ element){ var panes = $ scope.panes = [];
$scope.select = function(pane) {
angular.forEach(panes, function(pane) {
pane.selected = false;
});
pane.selected = true;
}
this.addPane = function(pane) {
if (panes.length == 0)
$scope.select(pane);
panes.push(pane);
}
},
template:
'<div class="tabbable">' +
'<ul class="nav nav-pills nav-stacked">' +
'<li ng-repeat="pane in panes" ng-class="{active:pane.selected}">'+
'<a href="" ng-click="select(pane)"> <i class="fa fa-list-alt fa-lg"></i></span> {{pane.title}}</a>' +
'</li>' +
'</ul>' +
'<div class="tab-content" ng-transclude></div>' +
'</div>',
replace: true
};
答案 0 :(得分:0)
您可以将hashtag写入href进行导航。
<a href="#/viewName">Navigate to a view</a>