1

I try to create an Angular JS function that is displaying or hiding a Div in case that a certain requirement is met. I do have the problem now that the function is not properly called and both divs are either visible or not visible (In the test case div 1 should be shown and div 2 not).

testApp.controller('MyController', ['$scope','$http',
function ($scope,$http) {
    $scope.checkValue = function(value){
    if(value >= 1)
        return true;
    else
        return false;
    };
}]);

In the html file I try to hide the Divs using the following parameters

<div class="classa" ng-hide="requestsExisting({{profile.arrayA.length}})">
<div class="classb" ng-hide="requestsExisting({{profile.arrayB.length}})">

Is during the run time the {{profile.parameterA.length}}passed to the function or the actual value that is stored in this variables? (It's 1 for arrayA and 0 for ArrayB)

1
  • i think you just need requestsExisting(profile.arrayA.length) Commented Nov 17, 2014 at 14:59

2 Answers 2

2

you don't need the "{{" sign. just do

<div class="classa" ng-hide="requestsExisting(profile.arrayA.length)">
<div class="classb" ng-hide="requestsExisting(profile.arrayB.length)">

the double curly brace is to put the value of the object in the html

The double curly brace notation {{ }} to bind expressions to elements is built-in Angular markup

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

Comments

1

I think that it should work just with this code

<div class="classa" ng-hide="requestsExisting(profile.arrayA.length)">
<div class="classb" ng-hide="requestsExisting(profile.arrayB.length)">

I think that you don't need to use {{}} inside the ng-hide directive

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.