我正在使用 ng-route 创建一个简单的 angularjs 应用程序,index.html 页面有一个 Bootstrap 轮播,当单击该按钮时,它有下一个和上一个按钮正在导航到下一个 Html 页面下面是我的 plunkr 链接以及我的 script.js 文件如果有误请更正,我已经搜索了很多但没有找到适合此问题的解决方案
var appname = angular.module('appname', ['ngRoute', 'ngAnimate']);
appname.config(['$routeProvider',
function ($routeProvider) {
$routeProvider.
when('/', {
templateUrl: 'indexView.html',
controller: 'indexController'
}).
when('/about', {
templateUrl: 'about.html',
}).
when('/contact', {
templateUrl: 'contact.html',
}).
otherwise({
redirectTo: '/'
});
}]).controller('MainCtrl', function($scope, $location) {
$scope.isIndexPage = function() {
return $location.path() === '/';
}
});
最佳答案
检查一下,现在一切正常。
http://plnkr.co/edit/JcInw9ZUz6vfFO5InV7N?p=preview
重写了 MainCtrl
部分,之前 MainCtrl
被创建一次并且从未更新过,但现在它监听路由变化并相应地隐藏轮播。
$scope.$on('$routeChangeSuccess', function () {
$scope.isIndexPage = $location.path() === '/';
});
关于javascript - Bootstrap Carousel 不适用于 Angular ng-route,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34993835/