我尝试运行一个类方法(在创建我的$uibModal
的控制器中)一旦模态"好的"按钮已被按下。我的理解是modalInstance
从组件返回一个模态对象,其中存在我的问题......我如何与父控制器而不是组件交互?
示例:
modalInstance.result.then(function () {
// if close() called in component, do this in the parent controller
this.users.splice(this.users.indexOf(user), 1);
}, function () {
// if dissmised, do this
console.log('modal-component dismissed at: ' + new Date());
});
这会引发错误:
TypeError:无法读取属性'用户'未定义的
这是一个带有关键项的Plunker: https://plnkr.co/edit/ZY3Kr9g3MuT1AxsQKfsj?p=catalogue
AngularJS 1.6,使用Angular Fullstack Generator 4.2.3
我已按照此文档:https://angular-ui.github.io/bootstrap/创建模态组件,模式效果很好。但无论我尝试什么,我都无法拼接我的用户群。请帮忙!
答案 0 :(得分:1)
可能是因为回调中绑定错误from __future__ import print_function
from AppKit import * # For development only. This takes a long time to complete as there are many symbols.
import fcntl
import os
import signal
shared_workspace = NSWorkspace.sharedWorkspace()
def on_did_activate_application(notification):
print('on_did_activate_application(notification = %s)' % notification)
notification_center = shared_workspace.notificationCenter()
did_activate_application_observer = notification_center.addObserverForName_object_queue_usingBlock_(
NSWorkspaceDidActivateApplicationNotification,
None,
None,
on_did_activate_application)
def handle_signal(signum, frame):
print('handle_signal(signum = %s, frame = <scrubbed>)' % signum)
if signum == signal.SIGCONT:
signal.signal(signal.SIGTSTP, handle_signal)
elif signum == signal.SIGINT:
notification_center.removeObserver_(did_activate_application_observer)
CFRunLoopStop(CFRunLoopGetCurrent())
else:
# https://stackoverflow.com/questions/13377773/proper-way-to-handle-signals-other-than-sigint-in-python
signal.signal(signum, signal.SIG_DFL)
os.kill(os.getpid(), signum)
r, w = os.pipe()
flags = fcntl.fcntl(r, fcntl.F_GETFL, 0)
fcntl.fcntl(r, fcntl.F_SETFL, flags | os.O_NONBLOCK)
def callout(f, call_back_types, info):
# Note: The signal handler will run first.
print('callout()')
# Clear the pipe of NUL bytes.
n = 0
while True:
try:
n += len(os.read(r, 100))
except OSError:
break
print('read %d byte(s)' % n)
# Per https://developer.apple.com/documentation/corefoundation/cffiledescriptor?language=objc
# "Each call back is one-shot, and must be re-enabled if you want to get another one."
# Thus we need to re-enable call backs.
CFFileDescriptorEnableCallBacks(f, kCFFileDescriptorReadCallBack)
file_descriptor = CFFileDescriptorCreate(None, r, True, callout, None)
CFFileDescriptorEnableCallBacks(file_descriptor, kCFFileDescriptorReadCallBack)
run_loop_source = CFFileDescriptorCreateRunLoopSource(None, file_descriptor, 0)
CFRunLoopAddSource(CFRunLoopGetCurrent(), run_loop_source, kCFRunLoopDefaultMode)
signal.set_wakeup_fd(w)
signal.signal(signal.SIGCONT, handle_signal)
signal.signal(signal.SIGINT, handle_signal)
signal.signal(signal.SIGTSTP, handle_signal)
# For testing, configure a SIGALRM to be received every two seconds.
signal.signal(signal.SIGALRM, lambda _1, _2: print('SIGALRM'))
signal.setitimer(signal.ITIMER_REAL, 2, 2)
print('about to call CFRunLoopRun()')
CFRunLoopRun()
,请尝试使用this
将其显式绑定到父封闭范围:
=>