Javascript AngularJS:ng repeat与JQuery相结合
这是我的密码: index.htmlJavascript AngularJS:ng repeat与JQuery相结合,javascript,jquery,angularjs,angularjs-ng-repeat,Javascript,Jquery,Angularjs,Angularjs Ng Repeat,这是我的密码: index.html <div ng-controller="WebsitesController as portfolioWebsites" class="content"> <ul class="grid cs-style-1"> <li ng-repeat="website in portfolioWebsites.items"> <figure> <img data-sr
<div ng-controller="WebsitesController as portfolioWebsites" class="content">
<ul class="grid cs-style-1">
<li ng-repeat="website in portfolioWebsites.items">
<figure>
<img data-src="img/{{website.img}}" data-effect="fadeInUp" alt="{{website.imgAlt}}">
<figcaption>
<div class="figcaption-container-inside">
<div class="element-title">{{website.title}}</div>
<div class="element-description-1">{{website.description}}</div>
<div class="element-description-2">{{website.date}}</div>
<button type="button" class="btn btn-dead coming-soon lang" ng-click="showLightDialog(website.dialog)"></button>
</div>
</figcaption>
</figure>
</li>
</ul>
除了一个细节之外,所有的东西都可以工作:在HTML中,在每次迭代中,onclick都包含参数lightDialog9,而不是使用我在JS文件lightDialog1、lightDialog2等中编写的内容
有人会知道这个问题吗?或者有没有更好的方法来处理这种情况,比如不使用JQuery
谢谢=
编辑:以下是我的函数LightDialog的代码:
基本上,它只添加能够显示或隐藏div的类。每个项有一个div。这是我创建的模态系统。使用角度的正确方法如下:
$scope.showLightDialog = function(website) {
$scope.dialog = website.title;
}
html代码如下所示:
<div class="dialog" ng-class="{dialog-shown: dialog == 'LightWolf Studios', dialog-hidden: dialog != 'LightWolf Studios'}">LightWolf Studios</div>
<div class="dialog" ng-class="{dialog-shown: dialog == 'Les Zappings', dialog-hidden: dialog != 'Les Zappings'}">Les Zappings</div>
最好是在object.id的顶部使用,但由于您的示例中没有id,所以我使用了title。这不是执行此操作的方法。不要将jQuery与angular一起使用。showLightDialog做什么?嗨,Mosho,谢谢你的回答,我用函数的代码编辑了我的帖子。你可以访问我的网站或在Hi Sergey的考试,谢谢你的回答。很抱歉,我是AngularJS和Javascript的真正初学者,所以我不太理解你的答案。我有4段代码:在HTML中,我有我创建的显示/消失divs弹出窗口的代码。2,我有我的网站列表的代码,当用户点击它们时,它会显示第一段代码。然后我使用JQuery函数使其出现和消失。最后,我使用angular脚本使第二段代码使用不同的项目重复。你现在能说得更准确些吗?非常感谢,我为您提供了一个不需要jquery的解决方案。要添加到角度控制器中以替换showLightDialog的函数。和要添加到弹出div标记中的代码。问题是显示或隐藏不够好,我需要在单击时添加或删除css类,因为添加/删除css类有很多css效果。基本上,我需要知道这个JQuery代码是否可以与AngularJS:$'.div1'。clickfunction一起使用{$'.div2.removeClass'myClass'}您不需要添加/删除类。此类有ng类。我将更新此情况的答案。
$scope.showLightDialog = function(website) {
$scope.dialog = website.title;
}
<div class="dialog" ng-class="{dialog-shown: dialog == 'LightWolf Studios', dialog-hidden: dialog != 'LightWolf Studios'}">LightWolf Studios</div>
<div class="dialog" ng-class="{dialog-shown: dialog == 'Les Zappings', dialog-hidden: dialog != 'Les Zappings'}">Les Zappings</div>