AngularJS&ui.bootstrap.modal service templateUrl - 我可以使用Angular路由吗?

Nic*_*ick 5 angularjs angular-routing angular-ui-bootstrap

我对Angular很新,但很喜欢它!我正在尝试创建一个模态对话框来显示局部视图.ui.bootstap.modal有一个选项,用于显示要显示的局部视图的URL.我在我的应用程序模块上配置了一个如下所示的路由:

angular.module('buggy').config(['$routeProvider',
    function($routeProvider) {
        $routeProvider.
        when('/lists', {
            templateUrl: 'views/lists/list.html'
        }).
        when('/lists/create', {
            templateUrl: 'views/lists/create.html'
        }).
        when('/lists/:listId', {
            templateUrl: 'views/lists/partials/view.html'
        }). //more stuff
Run Code Online (Sandbox Code Playgroud)

我想展示when(/lists/:listId)从上面的路线定义的部分模板.所以在我的控制器中我试图打开模态对话框,如下所示:

 $scope.showList = function (list) {
            $modal.open({
            templateUrl:'lists/' + list._id,
            scope:$scope
        });
    }
Run Code Online (Sandbox Code Playgroud)

模态对话框打开但内容正好[object].我是否需要在服务器端定义路由,还是可以使用Angular路由返回部分路由?

谢谢!

Nic*_*ick 5

我对 $routeProvider 的理解是有缺陷的。我责怪多年的 jQuery'n ;) 我现在已经开始工作了。我相信 $routeProvider 正在返回我的模块配置中定义的控制器实例;不是实际的模板。我已经像这样改变了我的代码:

 $scope.showList = function (list) {
        $scope.currentList = list;
        $modal.open({
            templateUrl: 'views/lists/modals/view.html',
            backdrop: false,
            scope: $scope,
            controller: 'modalCtrl'
        });
    }
Run Code Online (Sandbox Code Playgroud)

如果这不是一个好的解决方案..请发表评论。关于 Angular,我还有很多东西要学。

谢谢!