我想让模式窗口像这个网站一样打开不同的路由http://architizer.com/projects/rauchkuchlhaus-auf-der-seewiese-am-schliersee-1/
流程为:
- 为模式窗口创建路由状态
- 将模式打开逻辑放入
onEnter
属性中(当路由更改为当前状态时将运行) - 最后,所有项目(应该打开新的模式)都应该有引用来更改具有所需参数
ui-sref="home({foo: 'fooVal1'})"
的路由
你可以在ui路由器模式的常见问题中找到答案
$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('^');
});
}]
});