2016-10-14 8 views
0

authType은 login api에서 가져 오는 "basicUser"또는 "adUser"가 될 수 있습니다.Angularjs ng-show 값을 API 데이터와 동일하게 처리하는 방법

사용자 창이 API/로그인config.js (미안이 논리 혼란 스러워요)의 비교를 기반으로 표시됩니다. confic.js 파일의 authType 가용성을 기반으로보기 섹션을 갖습니다.

예 :

{ 
"authorities": [ 
    { 
     "authtype": "basicUser", 
     "token": { 
     "id": "wTLtMHbIVlKNQoR2htY3LQFlpt4ED3BLKxw", 
     "isvalid": true 
     }, 
     "user": { 
     "id": "admin", 
     "name": "Administrator", 
     } 
    } 
    ] 
} 

../api/login : 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> 
+0

는 "=== authType이 authType.basicUser를"=이'NG-쇼를 시도 NG-쇼에서 표현을 사용하지 않는 코드를 시도 {{}}에서 각도 지시문 –

+1

표현식을''''로 묶을 수 있습니다. ng-show = "authType === authType.basicUser"를 사용하면 [여기] (https://jsfiddle.net/Kunalh/04885499/10/) – Nishant123

+0

@ Angular_10을 참조하십시오. 그러면 ng-show = "authType === 'basicUser'"내가 언급 한 바와 같이 –

답변

0

당신이 필요 그나마`

<div ng-controller="userCntrl" ng-show="authType === authType.basicUser"></div> 
+0

예상되는 대신에 동일한 ng-show = "authType === authType.basicUser"가 반환됩니다. –

+0

사용자가 두 명인 경우에만 고정 된 두 명의 사용자 또는 많은 – Murali

+0

이 있습니다. ng-show = "authType.basciUser === 'basicUser'"사용자 이름이 핫 코드되어 있습니다. – Murali