【发布时间】:2017-08-04 17:52:37
【问题描述】:
我有两个 js 文件,app.js 和 datepicker.js。我与这里的 html 文件无关。在 datepicker.js 中有一个名为 clickApply() 的 JavaScript 函数。我想从 clickApply() 函数调用 app.js 文件中的另一个 submitDetails() 函数。怎么做?
angular.module('ctrl').controller('MyCtrl', ["$scope","$rootScope", function($scope, $rootScope){
$rootScope.submitDetails=function()
}]);//inside app.js
clickApply: function(e) { //inside datepicker.js
angular.element('#span').on("click",submitDetails());
this.hide();
this.element.trigger('apply.daterangepicker', this);
}
【问题讨论】:
-
只需像这样调用你的函数 submitDetails();
-
你的 clickApply 函数写在哪里?
-
我认为这可能是stackoverflow.com/questions/23648458/…的副本
-
如果您控制日期选择器的来源,我会将
submitDetails函数作为回调传递给日期选择器,然后在clickApply函数中调用回调。
标签: javascript jquery angularjs html css