我对刷新页面的问题感到困惑。示例:基本应用打开,网址为localhost:8000/dashboard
,然后我从菜单或其他任何位置转到用户标签,网址为localhost:8000/users/list
。如果我在用户上刷新页面,那么它将再次转到仪表板重新加载整个页面
后端正在正确处理它,当我做一个自定义状态并且没有指定' ng-admin'作为父母,它只停留在刷新的地方,但当我将父母添加到状态时,它会再次重新加载整个应用程序。
还启用了 html5mode 。
$locationProvider.html5Mode({
enabled: true,
requireBase: false
});
实体以ng-admin文档指定:
添加app.config(['NgAdminConfigurationProvider', 'RestangularProvider', function(nga, RestangularProvider) {
var admin = nga.application('Admin') // application main title
.debug(false) // debug disabled
.baseApiUrl('/api/'); // main API endpoint
var users = nga.entity('users');
admin
.addEntity(users);
users.listView()
.title('Admin users')
.fields([
nga.field('name')
.label('Name')
.isDetailLink(true),
nga.field('email')
.label('E-mail Address'),
nga.field('created', 'date')
.label('Created')
.map(fromNow),
nga.field('modified', 'date')
.label('Modified')
.map(transformDate),
nga.field('active', 'boolean')
.label('Status'),
nga.field('createdBy')
.label('Created by'),
]);
下一段代码
$rootScope.$on('$stateChangeSuccess', function (event, newUrl, oldUrl, newState, oldState) {
console.log('event:' , event);
console.log('newUrl:' , newUrl);
console.log('oldUrl:' , oldUrl);
console.log('newState:' , newState);
console.log('oldState:' , oldState);
})
从仪表板转到用户时提供输出:
event: {name: "$stateChangeSuccess", targetScope: p, defaultPrevented: false, currentScope: p, preventDefault: ƒ}
newUrl: {url: "?{search:json}&{page:int}&sortField&sortDir", params: {…}, parent: "listLayout", views: {…}, name: "list"}
oldUrl: {entity: "users", search: {…}, page: 1, sortField: null, sortDir: null}
newState: {parent: "ng-admin", url: "/dashboard?sortField&sortDir", params: {…}, controller: "DashboardController", controllerAs: "dashboardController", …}
oldState: {sortField: null, sortDir: null}
刷新时
event: {name: "$stateChangeSuccess", targetScope: p, defaultPrevented: false, currentScope: p, preventDefault: ƒ}
newUrl: {parent: "ng-admin", url: "/dashboard?sortField&sortDir", params: {…}, controller: "DashboardController", controllerAs: "dashboardController", …}
oldUrl: {sortField: null, sortDir: null}
newState: {url: "?{search:json}&{page:int}&sortField&sortDir", params: {…}, parent: "listLayout", views: {…}, name: "list"}
oldState: {entity: "users", search: {…}, page: 1, sortField: null, sortDir: null}
任何想法都赞赏。
答案 0 :(得分:0)
问题是我在标头控制器功能中有一个错误,它添加了去仪表板的方法,每次标题重新初始化时都会调用它。也许这会对某人有所帮助。