[英]Angular 1/Ui-router - Pass data from the state to controller
Here is my state : 这是我的状态:
.state({
name: 'contact.detail.read.step.overlay',
url: '',
abstract: true,
data: {
skipFooter: true,
cancelState: 'contact.detail.read'
},
views: {
'overlay@agent': {
component: 'overlayContent'
}
}
})
I want to run a method in this state that retrieves the name of the contact ( contactName
) and that it is recognized in the controller overlayContent
我想在此状态下运行一种方法,该方法可检索联系人的姓名( contactName
),并在控制器overlayContent
其识别overlayContent
normally I can access contact name in the overlayContent
controller if I add it to the bindings with : 通常,如果我使用以下方式将联系人姓名添加到绑定中,则可以访问overlayContent
控制器中的联系人姓名:
bindings: {
contactName: '<'
}
but I'm looking for a solution that does it without changing the bindings from the state, by adding it for example in the parameter data : 但我正在寻找一种解决方案,例如,将其添加到参数data中,而不改变状态的绑定:
data: {
name: contactName,
skipFooter: true,
cancelState: 'contact.detail.read'
},
You could resolve contactName: 您可以解析contactName:
.state({
name: 'contact.detail.read.step.overlay',
url: '',
abstract: true,
data: {
skipFooter: true,
cancelState: 'contact.detail.read'
},
views: {
'overlay@agent': {
component: 'overlayContent'
}
},
resolve: {
contactName: () => {
return 'what ever contactName should be';
}
}
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.