0

I use Angularjs on page for displaying numbers of notes:

<span ng-hide="currentCount.messages <= 0">{{currentCount.messages}}</span>

The value currentCount.messages is got from response AJAX in controller. Problem is that when I do reflesh browser page I see text {{currentCount.messages}} temporarily.

I tried to define in top controller: $scope.currentCount.messages = 0; but it did not help me.

4
  • Does "temply" mean that the placeholder is shown for a short time while the page is loading, and you don't want that? Commented May 13, 2015 at 18:08
  • 1
    read up on how ng-cloak works Commented May 13, 2015 at 18:09
  • 1
    Either add a spinner/loader that will show (ng-show="loading") while the content hides (ng-hide="loading") while loading the data, just set $scope.loading to true/false before/after the ajax. Or look into docs.angularjs.org/api/ng/directive/ngCloak Commented May 13, 2015 at 18:09
  • Sorry, temporarily Commented May 13, 2015 at 18:10

1 Answer 1

1

Try this:

<span ng-hide="currentCount.messages <= 0" ng-bind="currentCount.messages"></span>

Using ng-bind accomplishes the same thing, but you won't see the template string in the page before the angular finishes rendering.

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

1 Comment

Thanks It work, but below this code also: ng-class="{0:'hide'}[currentCount.messages]" and it takes value from init variable currentCount.messages, not after AJAX response, so I get wrong class hide then

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.