philosophocat
philosophocat

Reputation: 119

Angularjs expression behavior

Why? html:

<div ng-app="myApp">
    <div ng-controller="testCtrl">
        <div data-ng-show="{{tags.length > 2}}"><p>{{tags}}</p></div>
        <p>{{tags.length > 2}}</p>
    </div>
</div>

js:

.controller('testCtrl', function($scope){
        $scope.tags = 'Go go go';
    });

And shows only 'true'... Why div is hidden?

http://jsfiddle.net/3HT2F/11/

Upvotes: 0

Views: 36

Answers (1)

Davin Tryon
Davin Tryon

Reputation: 67296

As @user2422960 says, you just need to remove the {{ and }} because ng-show already expects an expression:

<div ng-app="myApp">
    <div ng-controller="testCtrl">
        <div data-ng-show="tags.length > 2"><p>{{tags}}</p></div>
        <p>{{tags.length > 2}}</p>
    </div>
</div>

Here is an updated fiddle.

Upvotes: 1

Related Questions