我有 2 条路线:
app.config(['$routeProvider', '$locationProvider', function(
$routeProvider, $locationProvider) {
$routeProvider.
when("/list/:class", {
controller: "listController",
templateUrl: "DatabaseObject",
reloadOnSearch: true
}).
when("/edit/:class/:id?", {
templateUrl: "editortemplate"
}).
otherwise("/custombrowsingstartpage");
}]);
他们都工作得很好!
我想要的是能够在“/list/:class”路由的模态窗口中呈现其中一条路由的“editortemplate”。
在我的“listController”中,我有模态打开功能:
$scope.showEditorPanel = function (size, a, b) {
//console.log($scope);
var modalInstance = $modal.open({
animation: true,
//templateUrl: '#/edit/'+b+'/'+a,
templateUrl: 'editortemplate',
controller: 'editorController',
size: size,
backdrop: true,
scope: $scope
});
模板呈现得很好,但我不知道如何将模板所需的类和 id 变量传递给它(如其路由所示)。
我尝试用变量(class== var b,id== var a)而不是模板 url 定义路由,但没有成功:
//templateUrl: '#/edit/'+b+'/'+a,
最佳答案
如果您添加一个“解决”对象,您可以发送您想要的内容,我相信这是使用 $modal 执行此操作的“Angular ”方式:
$scope.showEditorPanel = function (size, a, b) {
var modalInstance = $modal.open({
animation: true,
templateUrl: 'editortemplate',
controller: 'editorController',
size: size,
backdrop: true,
resolve: {
scope: function () {
$scope.properties.class = a;
$scope.properties.id = b;
return $scope.properties;
}
}
});
关于javascript - 模态内的 Angular 路线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32783936/