在模块上添加ngAnimate依赖项

时间:2014-09-30 03:55:08

标签: javascript angularjs

我已经将脚本链接到我的html文件中,用于angularjs,sanitize和animate:

<script type="text/javascript" src="js/angular.min.js"></script>
<script type="text/javascript" src="js/angular-sanitize.min.js"></script>
<script type="text/javascript" src="js/angular-animate.min.js"></script>
<script type="text/javascript" src="js/app.js"></script>

当我将ngAnimate作为依赖添加到我的模块时,就像这样:

var nameSpace = angular.module("OscarApp", ["ngSanitize","ngAnimate"]);

显示我表达式中的所有变量,因为它不是在变量上初始化的内容,就像这样:

{{item.award_title}}

似乎是什么问题?我只想学习本教程(https://www.youtube.com/watch?v=Bcv46xKJH98)。

2 个答案:

答案 0 :(得分:1)

适合我...... 这将2打印到屏幕

的index.html

<!DOCTYPE html>
<html ng-app="OscarApp">
<head>
  <meta charset="UTF-8">
  <title></title>
  <script type="text/javascript" src="angular.min.js"></script>
  <script type="text/javascript" src="angular-sanitize.min.js"></script>
  <script type="text/javascript" src="angular-animate.min.js"></script>
  <script type="text/javascript" src="app.js"></script>
</head>
<body>
  {{1+1}}
</body>
</html>

app.js

var nameSpace = angular.module('OscarApp', ['ngSanitize','ngAnimate']);

Angular version 1.3.0-rc.3(最新下载来自angularjs.org)

答案 1 :(得分:1)

此代码段显示该设备没有问题。 也许你在其他地方遇到了问题。

&#13;
&#13;
var nameSpace = angular.module('OscarApp', ['ngSanitize','ngAnimate']);

nameSpace.controller('OscarCtrl',['$scope',function($scope) {
    $scope.item={ 'award_title' : 'The Lord of The Rings' };
}]);
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular-sanitize.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular-animate.min.js"></script>
<div ng-app="OscarApp" ng-controller="OscarCtrl">
{{item.award_title}}
</div>
&#13;
&#13;
&#13;