re-update state
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).
- the full page for the product.
- 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'
Can you put this in a plnkr so we understand completely what you mean?
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) {
}]);
})();
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?
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.
why do they need the same url?
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.
Then whats the popup window for? Why not hide the url on that?
If the pop window has no url, the user can't copy or share the page.
But if the url is the same below the popup then they can copy that.
If the user us the url to access my web, it should display the detail page, not pop window.
+1
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.