JQuery 不工作 angularjs 控制器文件。如果代码片段放在内部则有效
JQuery not working angularjs controller file . Works if code snippet put internally
如果将下面的代码片段放在模板 URL 页面下,则可以正常工作。但是,如果我们将它放在单独的 js 文件或控制器文件中,它就不起作用。我如何在控制器文件中添加 jquery 。
<script>
$(document).ready(function () {
$("#notificationLink").click(function () {
$("#notificationContainer").fadeToggle(300);
$("#notification_count").fadeOut("slow");
$('#notificationLink > i.fa-bell').addClass('fa-bell-o');
$('#notificationLink > i.fa-bell').removeClass('fa-bell');
return false;
});
//Document Click hiding the popup
$(document).click(function () {
$("#notificationContainer").hide();
});
//Popup on click
$("#notificationContainer").click(function () {
return false;
});
/* $('#AddNew').on('click', function () {
$('#notificationsBody ul').append('<li>New Message</li>');
});
*/
});
</srcipt>
在 Angular 应用程序中使用 jQuery 的正确位置是在带有 jqlite 的指令中。你也可以把它放在控制器的同一个文件中,只要它在它之后。
如果将下面的代码片段放在模板 URL 页面下,则可以正常工作。但是,如果我们将它放在单独的 js 文件或控制器文件中,它就不起作用。我如何在控制器文件中添加 jquery 。
<script>
$(document).ready(function () {
$("#notificationLink").click(function () {
$("#notificationContainer").fadeToggle(300);
$("#notification_count").fadeOut("slow");
$('#notificationLink > i.fa-bell').addClass('fa-bell-o');
$('#notificationLink > i.fa-bell').removeClass('fa-bell');
return false;
});
//Document Click hiding the popup
$(document).click(function () {
$("#notificationContainer").hide();
});
//Popup on click
$("#notificationContainer").click(function () {
return false;
});
/* $('#AddNew').on('click', function () {
$('#notificationsBody ul').append('<li>New Message</li>');
});
*/
});
</srcipt>
在 Angular 应用程序中使用 jQuery 的正确位置是在带有 jqlite 的指令中。你也可以把它放在控制器的同一个文件中,只要它在它之后。