2016-10-14 9 views
0

私は、authTypeがログインAPIから取得する "basicUser"または "adUser"のいずれかのシナリオを持っています。Angularjs ng-show値の扱い方はAPIデータと同じです

Userウィンドウが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

を表現を使用していないこのコードを試してみてくださいangleディレクティブ –

+1

式を ''''の中で囲むことができます。 ng-show = "authType === authType.basicUser"を使用している場合は、[here](https://jsfiddle.net/Kunalh/04885499/10/) – Nishant123

+0

@ Angular_10を参照してください。 "authType === 'basicUser'"私が述べたように –

答えて

0

あなたが必要{{}}いけない `この` NG-ショー= "認証タイプ=== authType.basicUser" を試すNG-ショーに

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

これは、期待されるものではなく、同じng-show = "authType === authType.basicUser"を返します。 –

+0

ユーザが2人しかいない場合、固定ユーザー2人または多くの人が – Murali

+0

です。ng-show = "authType.basciUser === 'basicUser'"デフォルトでホットコードされたユーザー名 – Murali

関連する問題