0

In AngularJS, I want to use a scope variable defined in Javascript as 'propertySkipCount' in the HTML. I tried with {{propertySkipCount}} and also directly as propertySkipCount, but both does not work.

It only works if I substitute the variable with value like 1.

Javascript

 $scope.propertySkipCount = 1;

HTML

                <div class="form-group" ng-repeat="property in entity.entityPropertyTypes" ng-if="$index > propertySkipCount">



                <div class="form-group" ng-repeat="property in entity.entityPropertyTypes" ng-if="$index > {{propertySkipCount}}">

Update:

I want the code to look like below after substitution. If I hard code like below it works.

 <div class="form-group" ng-repeat="property in entity.entityPropertyTypes" ng-if="$index > 1">

Plunker

http://plnkr.co/edit/wMKa1dbeVNz3WfUojmjR?p=info

1
  • 1st method should work. Can your create a plunker? Commented Nov 19, 2015 at 11:16

3 Answers 3

1

The first method is works fine please check

<div class="form-group" ng-repeat="property in entity.entityPropertyTypes" ng-if="$index > propertySkipCount">
Sign up to request clarification or add additional context in comments.

2 Comments

He wants the variable inside ng-if and not print it in html.
Thanks will add Plunker.. vachitaanya aapu
1
<div class="form-group" ng-repeat="property in entity.entityPropertyTypes" ng-if="$index > propertySkipCount"> Test {{propertySkipCount}}</div>

Above code should work.

1 Comment

Thanks, that's just a code fragment I put. I have already closed in my application.
1

code looks fine . It should work , problem maybe with version you are currently using .

view:

<div ng-app>
  <h2>Todo</h2>
  <div ng-controller="TodoCtrl">
    <div class="form-group" ng-repeat="property in entityPropertyTypes" ng-if="$index > propertySkipCount">Hello ...! ++  {{$index}}</div>
  </div>
</div>

works fine with Angular 1.2.1

Not working as expected with Angular 1.1.1

2 Comments

Thanks I am using Angular 1.4.6
@Jay glad i could help buddie . are you sure you marked the right one as answer . cheers

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.