1

In the controller, I have this

var onComplete = function(response)
{
        $scope.reportList = response.data;      
        $log.info($scope.reportList);                       
};

In the HTML, reportList is a JSON like this {packageType=1, salary=12900 }. ReportList is not an array {{ reportList.packageTypeId }} return 1

The issue is with ng-if div

<div class="exceptionProcedure" ng-if=" reportList.packageType == 1"> 

<a> display package 1 </a>

when I tried this, it still does not work

<div class="exceptionProcedure" ng-if=" {{reportList.packageType}} == 1">

 <a> display package 1 </a>

Any ideas?

3
  • use ng-show instead of ng-if Commented Oct 12, 2015 at 4:01
  • The later one i.e. ng-if=" {{reportList.packageType}} == 1" is anyways wrong? Can you please print the type of packageType value? Something like: console.log(typeof $scope.reportList.packageType); Commented Oct 12, 2015 at 4:52
  • I got it fixed. Thanks. Missing the closing tag :) Commented Oct 12, 2015 at 11:39

1 Answer 1

1

You need to define reportList.packageType on the initial page load so that it links between your controller and view:

$scope.reportList = {}
var onComplete = function(response) {
    $scope.reportList = response.data;
    $log.info($scope.reportList);
};

This way, you'll only have one version that is shared between controller and view. The way you're doing it now creates two separate versions.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.