AngularJS:ui路由器:$state.includes不适用于具有默认参数的状态?
当我在做AngularJS:ui路由器:$state.includes不适用于具有默认参数的状态?,angularjs,angular-ui-router,Angularjs,Angular Ui Router,当我在做 $state.includes('courses.all({ clientType: "organizations" })') 它返回未定义的 而且它对你有用 $state.includes('courses.all') clientType在这里是可选参数(默认为“组织”) 那么这是一个bug还是一个特性呢 UPD: 它不仅仅适用于括号: $state.includes('courses.all()') 这是一项功能,$state.includes正在检查您提供的州名称是否存在
$state.includes('courses.all({ clientType: "organizations" })')
它返回未定义的
而且它对你有用
$state.includes('courses.all')
clientType
在这里是可选参数(默认为“组织”)
那么这是一个bug还是一个特性呢
UPD:
它不仅仅适用于括号:
$state.includes('courses.all()')
这是一项功能,$state.includes正在检查您提供的州名称是否存在于州全名中
示例:如果您有state:“app.state1.state2.state3”
,则state includes将为这些子状态中的任何一个返回true
另一方面,如果您想检查状态参数,则必须在路由器的“解析”中或直接在控制器中进行检查,$state.includes是一项功能,$state.includes检查您提供的状态名称是否存在于完整的状态名称中
示例:如果您有state:“app.state1.state2.state3”
,则state includes将为这些子状态中的任何一个返回true
另一方面,如果你想检查状态参数,你必须在路由器的resolve
中或直接在控制器中进行检查,我想你需要的是:
$state.includes('user.forms.preview', { type: 'patients' })
我的状态看起来像:
.state('user.forms.preview', {
page_title: 'Configuracion datos de Pacientes',
url: '/preview/:type',
controller: 'userFormPreviewerCtrl',
templateUrl: 'whathever.html',
})
你的情况是:
$state.includes('courses.all', { clientType: "organizations" })
我想你要找的是:
$state.includes('user.forms.preview', { type: 'patients' })
我的状态看起来像:
.state('user.forms.preview', {
page_title: 'Configuracion datos de Pacientes',
url: '/preview/:type',
controller: 'userFormPreviewerCtrl',
templateUrl: 'whathever.html',
})
你的情况是:
$state.includes('courses.all', { clientType: "organizations" })
谢谢你的回答,我在这里尝试实施它-谢谢你的回答,我在这里尝试实施它-它不仅希望为“组织”这样做它不仅希望为“组织”这样做