我试图在LoopbackJS,Angular和Angular-Materialize上编写项目。 我的app.js看起来像这样:
angular.module('MyApp', [
'ngRoute',
'ngResource',
'ui.router',
'lbServices',
'ui.materialize'
])
.config(['$stateProvider', '$routeProvider',
function ($stateProvider, $urlRouterProvider) {
$stateProvider
.state('index', {
url: '/',
templateUrl: 'views/authenticate.html',
service: 'AuthService',
controller: 'AuthCtrl'
})
.state('declarations', {
url: '/declarations',
templateUrl: 'views/declarations.html',
controller: 'DeclarationsCtrl'
})
.state('payments', {
url: '/payments',
templateUrl: 'views/payments.html',
controller: 'PaymentsCtrl'
})
.state('reports', {
url: '/reports',
templateUrl: 'views/reports.html',
controller: 'ReportsCtrl'
})
.state('services', {
url: '/services',
templateUrl: 'views/services.html',
controller: 'ServicesCtrl'
});
$urlRouterProvider.otherwise('/');
}])
.run(['$rootScope', '$state', function ($rootScope, $state) {
$rootScope.$on('$stateChangeStart', function (event, next) {
// redirect to login page if not logged in
if (next.authenticate && !$rootScope.currentAccount) {
event.preventDefault(); //prevent current page from loading
$state.go('forbidden');
}
});
}]);
在我的index.html中:
<script src="bower_components/jquery-2.1.4/dist/jquery.js"></script>
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/angular-route/angular-route.js"></script>
<script src="bower_components/angular-ui-router/release/angular-ui-router.js"></script>
<script src="bower_components/angular-resource/angular-resource.js"></script>
<script src="bower_components/angular-materialize/src/angular-materialize.js"></script>
当我加载JQuery 1.6.4时,我的所有路由都运行良好,我被重定向到authenticate.html页面。但是当我尝试使用更高版本时,我得到了index.html页面,在控制台中没有任何错误。我做错了什么?
P.S。我必须使用更高版本的JQuery,因为angular-materialize不适用于1.6.4。 感谢您的帮助:))