Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript angular js无法从状态解析状态_Javascript_Angularjs - Fatal编程技术网

Javascript angular js无法从状态解析状态

Javascript angular js无法从状态解析状态,javascript,angularjs,Javascript,Angularjs,我试图在一个名为single_post的状态中创建一个子状态memstate,以便使用single_post控制器达到此状态 $state.go(single_post({id:somename}); 但是我每次告诉我下面的事情都会出错 “错误:无法从状态‘single_post’解析‘single_post.memstate({id:somename})’” 下面是app.js代码 var app = angular.module('app',['ui.router','ui.rou

我试图在一个名为single_post的状态中创建一个子状态memstate,以便使用single_post控制器达到此状态

$state.go(single_post({id:somename});
但是我每次告诉我下面的事情都会出错 “错误:无法从状态‘single_post’解析‘single_post.memstate({id:somename})’”

下面是app.js代码

    var app = angular.module('app',['ui.router','ui.router.stateHelper','ngCookies']);
app.config(function($stateProvider){
index = {
    name : 'index',
    url : "",
    views : {
        'slider' :{
            templateUrl : 'template/slider.html',
            controller : 'slider_ctrl'
        },
        'content' : {
            templateUrl : 'template/posts-area.html',
            controller  : 'posts_ctrl'
        }
    }
};
single_post = {
    name : 'single_post',
    url  : '/t/{id:int}',
    views : {
        'content' : {
            templateUrl : 'template/single-post.html',
            controller  : 'single_post_ctrl'
        },
        'mem_handle' :{
            templateUrl :'template/lginform.html',
            controller : 'login_con'
        }
    }
};
loginstate = {
    name : 'single_post.loginstate',
    url : '/login',
    views : {
        'mem_handle' :{
            templateUrl :'template/lginform.html',
            controller : 'login_con'
        }

    }


};
regstate = {
    name : 'single_post.regstate',
    url  : '/register',
    views :{
        'mem_handle' :{
            templateUrl : 'template/regform.html',
            controller : 'reg_con'
        }
    }
};
memstate = {
    name : 'single_post.memstate',
    url : '/m/{id:string}/',
    views : {
        'content' : {
            template : 'member.html',
            controller : 'mem_controller'
        }
    }
}
$stateProvider.state('index',index);
$stateProvider.state('single_post',single_post);
$stateProvider.state('single_post.regstate',regstate);
$stateProvider.state('single_post.loginstate',loginstate);
$stateProvider.state('single_post.memstate',memstate);

});
谢谢大家,, 问题在于使用$state向状态传递参数。。 我发现正确的方法是

$state.go('single_post.memstate',{id:$cookies.get('an')});

通过将参数作为对象传递给函数$state.go()

您在
$state.go(single_post({id:somename}))中遗漏了一个括号有一次,我试着通过更正来检查。我试着放在括号中,但没有发生任何问题,我找到了问题的解决方案,非常感谢;)