2016-02-15 110 views
0

我得到未知的提供者:$ animateProvider ngAnimate我的angular.js文件中的錯誤。我檢查了在線解決方案,它說改變angular.animate.js文件的版本。我是否也必須更改angular.js文件的版本。我目前使用1.0.2版本。我將我的angular.animate.js版本從1.0.2修改爲1.2.6。但錯誤仍在。這是我的代碼。

<!doctype html> 
<html ng-app="MyApp" > 
<head> 
<meta charset="utf-8"> 
<title>AngularJS Plunker</title> 

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous"> 
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous"> 
<link rel="stylesheet" href="style.css"> 

</head> 

<body ng-controller="MyCtrl"> 
<form name='myform' ng-init="step = 1"> 

<div ng-show="step==1"> 
<div class="row"> 
<div class="col-sm-6"> <h3 class="bounceInDown">I am</h3> </div> 
<div ng-form='step1form'> 
<div class="col-sm-6"> 
<button type="submit" class="OptionButton repeat-animation" ng-disabled="!step1form.$valid" ng-click="step = 4"> 
<img src="SoundCloud.png" alt="Save icon"/> 
<br/> 
Self-employed Professional 
</button> 
<button type="submit" class="OptionButton" ng-disabled="!step1form.$valid" ng-click="step = 2"> 
<img src="SoundCloud.png" alt="Save icon"/> 
<br/> 
Self-employed Business 
</button> 
</div> 
</div> 
</div> 
</div> 

<div ng-show="step==2"> 
<div class="row"> 
<div class="col-sm-6"> <h3>I need a loan of</h3> </div> 
<div ng-form='step2form'> 
<div class="col-sm-6"> 
<button type="submit" class="OptionButton" ng-disabled="!step2form.$valid" ng-click="step = 3"> 
<img src="SoundCloud.png" alt="Save icon"/> 
<br/> 
1 lacs 
</button> 
<button type="submit" class="OptionButton" ng-disabled="!step2form.$valid" ng-click="step = 3"> 
<img src="SoundCloud.png" alt="Save icon"/> 
<br/> 
2 lacs 
</button> 
<button type="submit" class="OptionButton" ng-disabled="!step2form.$valid" ng-click="step = 3"> 
<img src="SoundCloud.png" alt="Save icon"/> 
<br/> 
3 lacs 
</button> 
<button type="submit" class="OptionButton" ng-disabled="!step2form.$valid" ng-click="step = 3"> 
<img src="SoundCloud.png" alt="Save icon"/> 
<br/> 
5 lacs 
</button> 
<button type="submit" class="OptionButton" ng-disabled="!step2form.$valid" ng-click="step = 3"> 
<img src="SoundCloud.png" alt="Save icon"/> 
<br/> 
10 lacs 
</button> 
<button type="submit" class="OptionButton" ng-disabled="!step2form.$valid" ng-click="step = 3"> 
<img src="SoundCloud.png" alt="Save icon"/> 
<br/> 
More than 10 lacs 
</button> 
</div> 
</div> 
</div> 
<div class="row"> 
<button ng-click="step = 1">Prev</button> 
</div> 
</div> 
</form> 
<script>document.write("<base href=\"" + document.location + "\" />");</script> 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script> 
<script src="bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script> 
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.js"></script> 
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.6/angular-animate.js"></script> 
<script src="app.js"></script> 
</body> 
</html> 

這裏是我的js文件

var app = angular.module("MyApp", ["ngAnimate"]); 
    app.controller('MyCtrl', function($scope, $timeout) { 
    $scope.name = '';  

    $scope.items = []; 
    $timeout(function(){ 
     for(i=0; i<4; i++) { 
     $scope.items.push(i); 
     } 
    }, 10); 
    }); 

回答

1

你需要確保你使用相同的版本,如果你用動畫1.2.6你還需要使用角1.2.6:

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.6/angular.js"></script> 
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.6/angular-animate.js"></script> 

FYI:當你在升級你不妨嘗試並升級到最新的舊版本在撰寫本書的時候的進度是爲1.2.29Ø r即使是最新的穩定1.5.0

相關問題