我有一个场景,authType可以是"basicUser"或"adUser",这将从登录api获取。
用户窗口将根据api/login和config.js之间的比较显示(对不起,我混淆了这个逻辑)。我将在conf .js文件中有一个基于authType可用性的视图部分。
: . ./api/登录
{
"authorities": [
{
"authtype": "basicUser",
"token": {
"id": "wTLtMHbIVlKNQoR2htY3LQFlpt4ED3BLKxw",
"isvalid": true
},
"user": {
"id": "admin",
"name": "Administrator",
}
}
]
}
: myconfig.js
{
"authType":{
"basicUser":"basicUser",
"adUser":"adUser",
}
}
view.html
<div ng-controller="userCntrl" ng-show="authType === {{authType.basicUser}}"></div>
<div ng-controller="userCntrl" ng-show="authType === {{authType.adUser}}"></div>
基于此,我得到ng-show="authType===basicUser",但预期的输出应该带有引号(' ')。
<div ng-controller="userDialogController" ng-show="authType === 'basicUser'"></div>
试试这段代码不要在ng-show中使用表达式
<div ng-controller="userCntrl" ng-show="authType === authType.basicUser"></div>