【问题标题】:How to make modal window open dynamic content and change url?如何使模态窗口打开动态内容并更改 url?
【发布时间】:2016-04-19 07:45:53
【问题描述】:

我想让模态窗口打开不同的路由,比如这个网站http://architizer.com/projects/rauchkuchlhaus-auf-der-seewiese-am-schliersee-1/

【问题讨论】:

  • 你能描述得更详细些吗?阅读您的问题的用户应该知道您想要什么,而无需离开本网站。
  • 请提供有关问题的更多信息。发布您想要达到的最终结果的图像比提供链接更好。此外,展示您的最新进展也很重要。

标签: javascript php angularjs routes modal-dialog


【解决方案1】:

流程是:

  1. 为模态窗口创建路由状态
  2. 将模态打开逻辑放在onEnter 属性中(将在路由更改为当前状态时运行)。
  3. 最后,所有项目(应该打开新的模态)都应该有引用来使用所需参数更改路线ui-sref="home({foo: 'fooVal1'})"

您可以在ui-router modal的常见问题中找到答案

$stateProvider.state("items.add", {
url: "/add",
onEnter: ['$stateParams', '$state', '$modal', '$resource', function($stateParams, $state, $modal, $resource) {
    $modal.open({
        templateUrl: "items/add",
        resolve: {
          item: function() { new Item(123).get(); }
        },
        controller: ['$scope', 'item', function($scope, item) {
          $scope.dismiss = function() {
            $scope.$dismiss();
          };

          $scope.save = function() {
            item.update().then(function() {
              $scope.$close(true);
            });
          };
        }]
    }).result.finally(function() {
        $state.go('^');
    });
}]
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-02-24
    • 1970-01-01
    • 1970-01-01
    • 2017-09-10
    • 1970-01-01
    • 1970-01-01
    • 2016-09-17
    相关资源
    最近更新 更多