Javascript 为什么不是';更新我的嵌套状态?我得刷新一下
我在初始注册localhost时有一个状态:3000/#!/这将显示一个新用户注册的启动页面。在您注册并登录之后,我保留了相同的url,并在其中有一个嵌套的部分视图,显示了用户的所有信息。代码如下:Javascript 为什么不是';更新我的嵌套状态?我得刷新一下,javascript,angularjs,angular-ui-router,mean-stack,Javascript,Angularjs,Angular Ui Router,Mean Stack,我在初始注册localhost时有一个状态:3000/#!/这将显示一个新用户注册的启动页面。在您注册并登录之后,我保留了相同的url,并在其中有一个嵌套的部分视图,显示了用户的所有信息。代码如下: <section data-ng-controller="IndexController"> <h1 mean-token="'home-default'">Hello {{global.user.name}}</h1> <div data-ng-if
<section data-ng-controller="IndexController">
<h1 mean-token="'home-default'">Hello {{global.user.name}}</h1>
<div data-ng-if="isLoggedOn() === true">
<div ui-view="docTool">
</div>
</div>
</section>
这是行不通的。我想用AngularUI路由器术语来说,显式调用$state将是一个绝对url,但也许我错了。我必须继续刷新以获得所需的视图。非常感谢任何能帮助我更好地理解这个问题的信息,谢谢
编辑这是我的路线图:
angular.module('mean.system').config(['$stateProvider', '$urlRouterProvider',
function($stateProvider, $urlRouterProvider) {
// For unmatched routes:
$urlRouterProvider.otherwise('/');
// states for my app
$stateProvider
.state('home', {
url: '/',
views:{
'':{
templateUrl: 'system/views/index.html'
},
'docTool@home':{
templateUrl: 'system/views/comps.html',
controller:'IndexController'
}
}
})
.state('test', {
url:'/test',
templateUrl:'system/views/index.html'
});
}
]).config(['$locationProvider',
function($locationProvider) {
$locationProvider.hashPrefix('!');
}
]);
因此,我认为问题不在于我的路线图。我认为这与我的服务有关,我的服务提供了部分视图中的内容。如果我查看我的http请求:
POST /login 200 271.102 ms - 320
{ _id: 53e11372727c4d911982784f,
email: 'test@test.com',
username: 'Tester123',
name: 'testing',
__v: 0,
provider: 'local',
roles: [ 'authenticated' ] }
GET /admin/menu/main 200 173.611 ms - 556
GET /test 200 228.396 ms - 71
这不显示视图。但在这里,当我刷新时,这是我的新http请求
GET / 200 184.150 ms - -
GET /system/views/header.html 304 170.272 ms - -
GET /system/views/comps.html 304 168.082 ms - - //THIS is different than other... why?
GET /system/views/index.html 304 173.343 ms - -
{ _id: 53e11372727c4d911982784f,
email: 'test@test.com',
username: 'Tester123',
name: 'testing',
__v: 0,
provider: 'local',
roles: [ 'authenticated' ] }
GET /admin/menu/main 304 167.281 ms - -
GET /test 304 220.457 ms - -
你能展示一下你的路线图吗?你有为“home”定义的路由吗?类似于$state('home',{url:'/home',等等)?@parsh用路由配置更新了问题。谢谢你看。你能试试
吗?@mohammadsepahv没有任何变化。所以,我拼凑了一些有用的东西。我的url没有指向$location.url('/');我将其更改为window.location=“/”,而$location似乎不起作用。似乎$location没有正确获取我的视图。
GET / 200 184.150 ms - -
GET /system/views/header.html 304 170.272 ms - -
GET /system/views/comps.html 304 168.082 ms - - //THIS is different than other... why?
GET /system/views/index.html 304 173.343 ms - -
{ _id: 53e11372727c4d911982784f,
email: 'test@test.com',
username: 'Tester123',
name: 'testing',
__v: 0,
provider: 'local',
roles: [ 'authenticated' ] }
GET /admin/menu/main 304 167.281 ms - -
GET /test 304 220.457 ms - -