ui-router icon indicating copy to clipboard operation
ui-router copied to clipboard

re-update state

Open kelp404 opened this issue 11 years ago • 12 comments

Hello,

There are some issue about this commit: https://github.com/angular-ui/ui-router/commit/48aeaff645baf3f42f5a8940ebd97563791ad9f8

My web has two states for the product page (same url but different templates and resolve).

  1. the full page for the product.
  2. the pop window at the index page.

I set the app.product before app.index.product. If the user type the url enter my web, it will go to app.product. If the user click the link on the index page, it will pop the window (go to app.index.product).

After https://github.com/angular-ui/ui-router/commit/48aeaff645baf3f42f5a8940ebd97563791ad9f8. When the user click the link on the index page, it will pop the window app.index.product then go to the product page app.product. ui-router re-update state again.

# the product page
$stateProvider.state 'app.product',
    url: '/{username:[\\w-]{2,16}}/products/{productId:[\\w-]{20}}'
    resolve:
        isInModal: -> no
    templateUrl: "/views/products/product.html"
    controller: 'ProductController'

# this route is for the pop window of the product page
$stateProvider.state 'app.index.product',
    url: '{username:[\\w-]{2,16}}/products/{productId:[\\w-]{20}}'
    resolve:
        isInModal: -> yes
    templateUrl: "/views/products/product-modal.html"
    controller: 'ProductController'

kelp404 avatar Sep 08 '15 09:09 kelp404

Can you put this in a plnkr so we understand completely what you mean?

eddiemonge avatar Sep 09 '15 18:09 eddiemonge

Hi @eddiemonge

Here you are http://plnkr.co/edit/GyhxUnWdPdB6PxYo686q?p=preview

When I click product-modal.html it will print this at console.

state change success to index.product
state change success to product
(function () {
  var app = angular.module('app', ['ui.router']);

  // routers
  app.config(['$stateProvider', '$urlRouterProvider', '$locationProvider', function ($stateProvider, $urlRouterProvider, $locationProvider) {
    $locationProvider.html5Mode({
      enabled: false,
      requireBase: false
    });

    $urlRouterProvider.otherwise(function ($injector, $location) {
      $state = $injector.get('$state');
      $state.go('index', null, {
        reload: true,
        location: 'replace'
      });
    });

    $stateProvider.state('index', {
        url: '/',
        template: [
          "<div ui-view>",
          "<h2>Index</h2>",
          "<h3><a href='#/product'>product.html</a></h3>",
          "<h3><a href='#/product' ng-click='go($event)'>product-modal.html</a></h3>",
          "</div>"
          ].join(''),
        controller: ['$scope', '$state', function ($scope, $state) {
          $scope.go = function ($event) {
            $event.preventDefault();
            $state.go('index.product');
          };
        }]
    });

    $stateProvider.state('product', {
        url: '/product',
        templateUrl: "product.html",
        controller: 'ProductController'
    });

    $stateProvider.state('index.product', {
        url: 'product',
        templateUrl: "product-modal.html",
        controller: 'ProductController'
    });
  }]);

  app.run(['$rootScope', function ($rootScope) {
    $rootScope.$on('$stateChangeSuccess', function (event, toState, toParams, fromState, fromParams) {
      console.log('state change success to ' + toState.name);
    });
  }]);

  // controllers
  app.controller('ProductController', ['$scope', function ($scope) {

  }]);
})();

kelp404 avatar Sep 10 '15 04:09 kelp404

You basically have two states with the same url. I'm not entirely sure what you expect to happen with that. @christopherthielen what do you think should happen here? Or should we not worry about it with 1.0?

eddiemonge avatar Sep 11 '15 21:09 eddiemonge

Thank you. This is my website. https://soramarket.com/

Because I want to let the pop window at index page and the detail page have the same url. But the pop window and the detail page have different template.

kelp404 avatar Sep 12 '15 00:09 kelp404

why do they need the same url?

eddiemonge avatar Sep 12 '15 00:09 eddiemonge

For user experience.

If user click the product on index page. It will change url but it just pop the window (after the user close the window, he can continue scroll down to view other products). When the user copy the url of the pop window to share, the other user who use the url will access to the detail page not pop window.

kelp404 avatar Sep 12 '15 04:09 kelp404

Then whats the popup window for? Why not hide the url on that?

eddiemonge avatar Sep 12 '15 17:09 eddiemonge

If the pop window has no url, the user can't copy or share the page.

kelp404 avatar Sep 13 '15 00:09 kelp404

But if the url is the same below the popup then they can copy that.

eddiemonge avatar Sep 14 '15 19:09 eddiemonge

If the user us the url to access my web, it should display the detail page, not pop window.

kelp404 avatar Sep 15 '15 01:09 kelp404

+1

dracula92107 avatar Apr 29 '16 03:04 dracula92107

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

This does not mean that the issue is invalid. Valid issues may be reopened.

Thank you for your contributions.

stale[bot] avatar Jan 24 '20 10:01 stale[bot]