ngRoute no longer working after injecting ngAnimate

元气小坏坏 提交于 2019-12-13 01:19:38

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!