Javascript Angular Js中的引导选项卡不起作用
我正在创建一个angular js应用程序。它有一个侧栏导航系统。当我单击侧边栏项目时,它必须在内容部分显示该项目下的内容,我正在使用引导 看到我写的代码了吗 HTMLJavascript Angular Js中的引导选项卡不起作用,javascript,jquery,angularjs,twitter-bootstrap,Javascript,Jquery,Angularjs,Twitter Bootstrap,我正在创建一个angular js应用程序。它有一个侧栏导航系统。当我单击侧边栏项目时,它必须在内容部分显示该项目下的内容,我正在使用引导 看到我写的代码了吗 HTML <div class="sidebar"> <ul> <li ng-repeat="item in supplyItem"> <a class="span" href="#{{item.he
<div class="sidebar">
<ul>
<li ng-repeat="item in supplyItem">
<a class="span" href="#{{item.header}}">{{item.header}}</a>
</li>
</ul>
</div>
<div class="content-part">
<div class="tab-content">
<div class="tab-pane" ng-repeat="item in supplyItem" id="{{item.header}}">
{{item.desc}}
</div>
</div>
但当我点击侧边栏导航项时,它会进入主页,正如我在routeProvider中提到的那样
错误是什么?如何解决?请任何人帮帮我我认为您的点击窗格div的ID应该不同:
id=“item.header”应该是id=“{item.header}}”另外,我注意到在你的JS中你有: $scope.supplyItem=[ { “header”:“header1”, “说明”:“说明1” }, { “header”:“header1”, “说明”:“说明2” } ];
我认为“header”值应该是不同的,以便引导插件区分不同的div。ohh,这是一个问题错误,实际上就像你在我的原始代码中所说的,我编辑了codeOk,在这种情况下,header属性被分配给a href att,我认为它们应该是/home和/supplies。我想这是另一个打字错误吗?;)我不明白,你是什么意思?哦,我搞错了。您是否可以尝试使用console.log或其他东西调试侧栏单击侦听器,以查看它是否被调用?因为我认为您正在使用$selector,它没有得到任何值,因为AngularJS尚未将这些项放入DOM。我添加了一个警报beofre,但它没有接收,即事件运行不正常,这就是我所想的。我认为您应该使用ng单击指向侦听器的选项卡div。这样你就能确保它的角度安全
myApp.config(['$routeProvider',function($routeProvider){
$routeProvider.
when('/home',{
templateUrl : 'partials/home_page.aspx',
controller:'HomePageController',
}).
when('/supplies',{
templateUrl : 'partials/supplies.aspx',
controller:'MyController',
}).
otherwise({
redirectTo: '/home'
});
}]);
appController.controller('MyController', ['$scope', function ($scope) {
$scope.supplyItem = [
{
"header": "header1",
"desc": "Descipriotn 1"
},
{
"header": "header2",
"desc": "Descipriotn 2"
}
];
$('.sidebar a').click(function (e) {
e.preventDefault();
$(this).tab('show');
});
$(function () {
$('.sidebar a:last').tab('show');
});
} ]);