如何从指令中的其他模块调用方法
How to call method from other module in directive
我的应用程序是这样的:
angular.module('app', [
// other includes
'ui.bootstrap'
])
在我的指令中,我正在处理:
angular.module('app').directive('DateFields','DatepickerController', ['$timeout', 'DatepickerController', function ($timeout, DatepickerControlle) {
return {
restrict: 'A',
replace: true,
templateUrl: 'path to calendar.html',
scope: {
element: "=",
flowParameterMap: "=?"
},
controller: ['$scope', '$element', '$timeout', function (scope, element, $timeout) {
if (!scope.element)
return;
scope.overlayClick = function (e)
{
scope.isOpen = true;
var input = $(e.currentTarget).next();
$timeout(function () {
$(input).focus();
$DatepickerController.isOpen = true;
});
}
}]
};
}]);
正如您所看到的,我正在尝试从datepickers isOpen变量的代码更改值来显示绑定到另一个dom对象的datepicker。但我所有的尝试都以"未定义"错误告终。
在你的指令中试试这个:
scope: {
element: "=",
isOpen: "=",
flowParameterMap: "=?"
},
现在您应该能够更改isOpen值。
相关文章:
- 在BoilerplateJS浏览器加载所有脚本(在其他模块中),而不考虑激活的模块
- 将路由处理程序委托给NodeJS+Express中的其他模块
- 如何从指令中的其他模块调用方法
- 使用其他模块中的函数,避免异步回调地狱
- 其他模块中的节点事件发射器
- 使用Angular JS将常量注入其他模块配置
- 如何将全局变量放在Globals.js模块中,并在其他模块中访问它们
- 是否可以访问同一文件中的其他模块导出功能
- $window对象在其他模块中不可用
- RequireJS - 先初始化一个依赖模块,然后再加载其他模块
- Dojo构建没有't包括dojo/dom、dom/when、dojo/dom-class和大约100个其他模块
- require.js-无法加载任何其他模块
- Joomla下拉菜单在其他模块后面
- 如何使用Typescript / node.js让一个模块中的函数直接在其他模块中可用?
- 无法在expressJs的其他模块中导入app.js
- moment.js作为AMD模块加载时静默失败.其他模块都没问题
- 使用python电子邮件或其他模块在电子邮件中发送散景图
- 我如何创建一个变量,可以在其他模块中编辑,而不是全局
- Facebook JS SDK与其他模块:或者,为什么有Java代码的差异
- 在其他模块中使用require时获得未定义属性