问题
I wanted to animate my application so I injected ngAnimate but now none of my views are displaying:
var spApp = angular.module('spApp', ['ngRoute','ui.bootstrap', 'ngAnimate'])
.config(function($routeProvider, $locationProvider){
var rootUrl = '/Style%20Library/projects/spDash/app/partials/';
$routeProvider
.when('/home',
{
templateUrl: rootUrl+'home.html'
})
.when('/userView',
{
templateUrl: rootUrl+'userView.html',
controller: 'userCtrl'
})
.when('/groupView',
{
templateUrl: rootUrl+'groupsView.html',
controller: 'groupCtrl'
})
.when('/sitesView',
{
templateUrl: rootUrl+'sitesview.html',
controller: 'sitesCtrl'
})
.otherwise({redirectTo:'/home'});
//$locationProvider.html5Mode(true);
});
Is this incorrect?
回答1:
Your application demo in the plunker is missing the app declaration like this for example:
<body ng-app="spApp">
There is controller or main controller defined.
<div ng-controller="mainCtrl">
<ng-view></ng-view>
</div>
More over I am not sure about your script declaration.
Here is a plunker configured:
http://plnkr.co/edit/tjDnzBu2PVSADKtbEFrL?p=preview
Here's a plunker with a few HTML files. In the original, you had "home.js" instead of "home.html", but when the partials are saved as HTML they seem to work fine.
http://plnkr.co/edit/aa6fKoBljxRHe4zVPYBl?p=preview
回答2:
The version between angular and animate weren't the same. Angular was 1.2.4 while animate was 1.2.10.
Upgrading angular solved the issue.
Thanks for trying.
来源:https://stackoverflow.com/questions/21562363/ngroute-no-longer-working-after-injecting-nganimate