gpt4 book ai didi

javascript - 我似乎无法运行 ngAnimate?

转载 作者:行者123 更新时间:2023-11-28 07:13:19 26 4
gpt4 key购买 nike

我有 ngAnimate 依赖注入(inject)问题。我不知道为什么,但每当我将 ngAnimate 作为依赖项包含在我的 js 代码中时,它就不起作用......这不是剧本...

我有这个 html 代码:

<!doctype html>
<html ng-app="myApp">
<head>


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

<script src="codebuttonewb.js"></script>

<style>
.hidden{
display:none;
}
ul{
//display:flex;
margin-bottom:10px;
list-style-type: none;
}
li span{
display:inline-block;
line-height:50px;

}
li img{
margin-right:10px;
border-radius:50%;
width:50px;
height:50px;
}
</style>
</head>
<body ng-controller="myController">
<input type="text" ng-model="search" placeholder="search">
<ul ng-class="{'hidden' : !toggle}"><!-- if this value is false then show the class of hidden -->
<li ng-repeat="item in list | filter:search"
ng-class="item.age>29 ? 'over-thirty' : 'under-thirty'">

<img ng-src="{{item.img}}"/>
<span> {{item.name}} - <em>{{item.age}}</em></span>
</li>

</ul>
<button ng-show="!toggle" ng-click="toggle=true" >show names</button>
<button ng-show="toggle" ng-click="toggle=false">hide names</button>
<form ng-submit="addPerson()">

<input type="text" placeholder="name" ng-model="name"/>
<br/>
<input type="number" placeholder="age" ng-model="age"/>
<br/>
<input type="submit" value="submit" />

</form>

</body>

</html>

这个js代码:

angular.module('myApp', ['ngAnimate'])
.controller("myController",function($scope){


$scope.toggle =true;


$scope.list=[
{name:'bla',age:28,img: 'https://s3.amazonaws.com/uifaces/faces/twitter/brad_frost/128.jpg'},
{name:'blabla',age:38,img: 'https://s3.amazonaws.com/uifaces/faces/twitter/mlane/128.jpg'},
{name:'blaba',age:23, img:'https://s3.amazonaws.com/uifaces/faces/twitter/felipenogs/128.jpg'},
{name:'blablala',age:56, img:'https://s3.amazonaws.com/uifaces/faces/twitter/adellecharles/128.jpg'}
];


$scope.addPerson= function(){
$scope.list.push({name:$scope.name,age:$scope.age});
$scope.name="";
$scope.age="";
};
});

任何解决方案都将受到欢迎。这是我第一次使用 ngAnimate,所以我想这可能是一些愚蠢的事情。

最佳答案

我以前也遇到过类似的问题。尝试改变:

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

至:

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

关于javascript - 我似乎无法运行 ngAnimate?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31089025/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com