0
问题
我使用UI引导的dialog
服务在我的应用程序,该服务创建模态对话框,我这样做,使用下面的方法对我的外表$scope
:将数据传递给角的嵌套控制器
$scope.showRouteEditDialog = function (template, route) {
// argument `route` is not currently used
var dialog = $dialog.dialog({
backdrop: true,
keyboard: false,
backdropClick: true,
templateUrl: template,
controller: 'RouteController'
});
dialog.open().then(function(result) {
alert(result); // This line is called when dialog is closed
});
}
这种方法在后面从局部视图调用以下标记
<a href="#" ng-click="showRouteEditDialog('Templates/Content/Timeline/Item/Editor.html', route)"><i class="halflings-icon edit"></i></a>
我的对话处理一个的编辑(route
是主模型内的子模型),所以我想这条路线传递给对话框,这样它会认为是它自己的模式,无需了解外部模型什么。
我对这个问题初始猜测是对的路线参数分配给dialog
变量,像dialog.route = route
,并在以后控制器中使用下面的代码:尽管此方法创建一个依赖,没有按
Application.controller('RouteController', ['$scope', 'dialog', function ($scope, dialog) {
// `dialog` is our dialog and it is injected with injector
doSomethingWith(dialog.route)
}]);
看起来像一个角度的做事方式
我也发现this post说我应该使用服务的目的,但它似乎像这个解决方案是这样一个小问题矫枉过正。
问题什么是从外控制器值传递给一个内层一个上的场景上述的角的方式。
谢谢
谢谢里面的 “路线” 的价值,它的工作,但它是如何工作的?我以前没有使用“解决方案”。它是什么? – Lu4
“成员将得到解决,并传递给控制器当地人” - 来自:https://github.com/angular-ui/bootstrap/blob/master/src/dialog/README.md 你也有它在ui路由器或$ route服务作为将用例特定参数传递到通用控制器的一种方式 –
谢谢,真正有用的帖子... – Lu4