如何在 angularjs 模态窗口中运行 jquery
How to run jquery inside angularjs modal window?
我在angularjs中使用ngDialod作为我的模态窗口。
我想在模态窗口中运行一些jQuery代码。
我创造了一个小提琴我的模态。如何在点击时定位id="target"
?
(为什么我需要这个,因为我正在计划在模态中一个简单的图像滑块)
请帮忙,
你的答案
http://jsfiddle.net/mb6o4yd1/6/
<div ng-controller="MyCtrl">
<button ng-click="clickToOpen()">My Modal</button>
<script type="text/ng-template" id="templateId">
<div id="target" ng-click="test()" ng-controller="tt">
Click here
</div>
</script>
</div>
var myApp = angular.module('myApp',['ngDialog']);
//myApp.directive('myDirective', function() {});
//myApp.factory('myService', function() {});
function MyCtrl($scope, ngDialog) {
$scope.clickToOpen = function () {
ngDialog.open({ template: 'templateId' });
};
}
function tt($scope)
{
$scope.test = function()
{
console.log("AaA");
}
}
您可以将控制器传递给ngDialog并使用ng-click。
var myApp = angular.module('myApp',['ngDialog']);
//myApp.directive('myDirective', function() {});
//myApp.factory('myService', function() {});
function MyCtrl($scope, ngDialog) {
$scope.clickToOpen = function () {
ngDialog.open({ template: 'templateId',
controller : 'dialogCtr'});
};
}
myApp.controller('dialogCtr', function($scope){
$scope.clickTarget = function()
{
alert("hello");
};
});
<div ng-controller="MyCtrl">
<button ng-click="clickToOpen()">My Modal</button>
<script type="text/ng-template" id="templateId">
<div ng-click="clickTarget()" id="target">
Click here
</div>
</script>
</div>
相关文章:
- 对动态创建的元素运行jQuery.ech()
- 如何在加载角度函数后运行jQuery代码
- 在AJAX jQuery加载()之后运行jQuery代码
- 如何仅在设备基于 iOS 时运行 jQuery 代码
- 使用 .on 函数运行 jQuery 声明函数
- html代码没有运行jquery问题
- 仅在尚未运行jQuery UI的情况下运行动画
- 在运行jquery之前从5开始倒计时
- 在不重新运行jquery验证的情况下检查表单是否有效
- 在Angular App中运行jQuery函数
- 一旦设置了PHP查询字符串,如何运行jQuery脚本
- 如何在Ember中更改模板时运行JQuery代码
- 如果URL包含字符串don't运行jQuery函数
- 在php之前运行jQuery脚本
- 无法动态地将 jquery 添加到头部并运行 jquery 代码
- 在 HTML 中运行 jquery 脚本
- 如何在控制器外部和视图内在 AngularJs 中运行 jQuery
- 在具有相同类的每个表上运行 jquery
- 在 Angular 完成渲染后运行 JQuery 代码
- 如何选择当前 DIV ID 以使用该 ID 运行 Jquery