Ui-router嵌套视图不能正确加载
ui-router nested view doesn't get loaded properly
嘿,我已经创建了一个简单的应用程序。
应用程序有以下视图
1。设置 -主视图。
2。配置文件 -子视图,设置视图的子视图。
3。帐户 -子视图,设置视图的子视图。
我希望应用程序从配置文件页开始,因此我编写了以下代码:
$urlRouterProvider.otherwise('/profile');
但显然没有发生,我得到了一个空白屏幕,不能正确地看到视图(settings.profile)。
我已经将我的代码添加到一个柱塞,使事情更方便和可访问的其他开发人员,可以帮助我解决我的问题。https://plnkr.co/edit/RFP5dUNV876cy8vRDuvL?p=preview
Main Main代码如下:
/**
* Module
*
* Description
*/
var app = angular.module('app', ['ui.router'])
app.controller('mainCtrl', ['$scope', function($scope){
$scope.title="Index Page";
}]);
app.controller('ProfileController', ['$scope', function($scope){
$scope.title="Profile Page";
}]);
app.controller('AccountController', ['$scope', function($scope){
$scope.title="Account Page";
}]);
app.controller('SettingsController', ['$scope', function($scope){
$scope.title="Settings Page";
}]);
app.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('settings', {
url: '/settings',
templateUrl: 'settings.html',
controller: 'SettingsController'
})
.state('settings.profile', {
url: '/profile',
templateUrl: 'profile.html',
controller: 'ProfileController'
})
.state('settings.account', {
url: '/account',
templateUrl: 'account.html',
controller: 'AccountController'
});
$urlRouterProvider.otherwise('/profile');
});
将.otherwise
函数更改为:
$urlRouterProvider.otherwise('/settings/profile');
由于其他路由嵌套在settings
状态中,您只能通过settings.html
中的<ui-view>
访问嵌套视图。如果在两者中都定义了url
参数,则url也会彼此嵌套,因此需要/settings/profile
。
相关文章:
- 如果数据为空,Ajax加载不会停止
- FileReader加载不在控制器范围Angular 2内
- requireJS 中的车把加载不成功
- 关闭-库加载不正确
- 弹出加载不起作用
- jQuery UI加载不正确?找不到对话框方法
- GULP中的Ctrl+S之后,实时重新加载不起作用
- 在解决Firebase GetRecord之前,视图加载不完整
- 网页加载不正确:'"JSON”;未定义'错误
- 加载不是来自“xampp的htdocs”或“root”文件夹的图像
- 阻止推特分享按钮加载不正确
- Durandal View偶尔加载不正确,而且总是在缩小时加载不正确
- 影子盒加载不起作用
- 传单显示悬停时的地图 - 地图加载不正确
- 余烬 CLI 实时重新加载不起作用
- 在Javascript中保存和加载不起作用
- 图像加载不能正常执行
- 偶尔懒惰加载不会;Don’我不能在有角度的情况下工作
- templateUrl资源加载不能使用webpack
- 隐藏的东西,而通过jquery加载不能正常工作