如何将函数添加到 $mdDialog.show AngularJS Material
How to add function into $mdDialog.show AngularJS Material
我使用 angularJS material 对话框来创建弹出窗口 window,我想在其中输入完成某项任务需要多长时间。我想使用 bootstrap-datepicker 并且我必须为我的输入分配函数,
angular.element(".timepicker").timepicker({
showInputs: false
});`
但问题是当这个函数被命中时,那个元素不存在。
这是我的控制器函数:
$scope.showCompleteConfirm = function (ev) {
//Timepicker
angular.element(".timepicker").timepicker({
showInputs: false
});
$mdDialog.show({
controller: UserDetailController,
templateUrl: 'app/components/templates/CustomTimeDialog.html',
parent: angular.element(document.body),
targetEvent: ev,
clickOutsideToClose: true,
fullscreen: false // Only for -xs, -sm breakpoints.
})
.then(function (answer) {
//success
}, function () {
//fail
});
};
我能做的和它的工作是在我的 HTML 页面中创建标签并从那里分配它,因为当调用此模板时,我的输入将存在,但我想知道是否有是一种如何使其仅在控制器中与我的功能一起使用的方法。
我不完全确定,但我认为 $mdDialog
有一个 onComplete
生命周期钩子可以使用。它在 show()
完成后被触发 运行。
$mdDialog.show({
controller: UserDetailController,
templateUrl: 'app/components/templates/CustomTimeDialog.html',
parent: angular.element(document.body),
targetEvent: ev,
clickOutsideToClose: true,
fullscreen: false // Only for -xs, -sm breakpoints.
onComplete: function (){
angular.element(".timepicker").timepicker({
showInputs: false
});
}
})
我使用 angularJS material 对话框来创建弹出窗口 window,我想在其中输入完成某项任务需要多长时间。我想使用 bootstrap-datepicker 并且我必须为我的输入分配函数,
angular.element(".timepicker").timepicker({
showInputs: false
});`
但问题是当这个函数被命中时,那个元素不存在。
这是我的控制器函数:
$scope.showCompleteConfirm = function (ev) {
//Timepicker
angular.element(".timepicker").timepicker({
showInputs: false
});
$mdDialog.show({
controller: UserDetailController,
templateUrl: 'app/components/templates/CustomTimeDialog.html',
parent: angular.element(document.body),
targetEvent: ev,
clickOutsideToClose: true,
fullscreen: false // Only for -xs, -sm breakpoints.
})
.then(function (answer) {
//success
}, function () {
//fail
});
};
我能做的和它的工作是在我的 HTML 页面中创建标签并从那里分配它,因为当调用此模板时,我的输入将存在,但我想知道是否有是一种如何使其仅在控制器中与我的功能一起使用的方法。
我不完全确定,但我认为 $mdDialog
有一个 onComplete
生命周期钩子可以使用。它在 show()
完成后被触发 运行。
$mdDialog.show({
controller: UserDetailController,
templateUrl: 'app/components/templates/CustomTimeDialog.html',
parent: angular.element(document.body),
targetEvent: ev,
clickOutsideToClose: true,
fullscreen: false // Only for -xs, -sm breakpoints.
onComplete: function (){
angular.element(".timepicker").timepicker({
showInputs: false
});
}
})