1

I have a question.

In this code

{{gridOptions4[0].no}}

output is 1.

but in this code:

var i=0;
{{gridOptions4[i].no}} 

output is no data.

Why is this value coming out?

2
  • That is because you have probably not made i as a class variable. You use angular or angularjs? Commented May 31, 2018 at 3:43
  • angular js ....... Commented May 31, 2018 at 7:53

1 Answer 1

2

To get the value in your html file use $scope.i=0;, if you use var i = 0;, it means its local variable, in view it will not able to use the value of i. The following change will work for you:

$scope.i=0;
{{gridOptions4[i].no}} 
Sign up to request clarification or add additional context in comments.

10 Comments

<div class="gallery"> <% for (var i=0; i < {{gridOptions4[i].name}}; i++) { %> <div class="{{gridOptions4[0].class}}"> <div class="gallery-item"> <a href="{{gridOptions4[0].main_href}}"> <div class="gallery-item-image"> <img ng-src="{{gridOptions4[0].imgsrc}}"></div> </a> <div class="gallery-item-description"> <p align="center">{{gridOptions4[0].name}}</p> </div> </div> </div> <% } %> </div>
but Unexpected token { in D:\OneDrive\디자인과제\1.개발 코드\1.Design_Web\views\concept.ejs while compiling ejs If the above error is not helpful, you may want to try EJS-Lint: github.com/RyanZim/EJS-Lint
full code is <div ng-app="myApp" ng-controller="BasicCtrl20"> <div class="posts"> <div class="gallery"> <% for (var i=0; i < {{gridOptions4[i].name}}; i++) { %> <div class="{{gridOptions4[i].class}}"> <div class="gallery-item"> <a href="{{gridOptions4[i].main_href}}"> <div class="gallery-item-image"> <img ng-src="{{gridOptions4[i].imgsrc}}"></div> </a> <div class="gallery-item-description"> <p align="center">{{gridOptions4[0].name}}</p> </div> </div> </div> <% } %> </div> </div>
<div ng-app="myApp" ng-controller="BasicCtrl20"> <div class="posts"> <div class="gallery"> <div ng-repeat = "gridoptions in gridOptions4"> <div class="{{gridOptions.class}}"> <div class="gallery-item"> <a href="{{gridOptions.main_href}}"> <div class="gallery-item-image"> <img ng-src="{{gridOptions.imgsrc}}"> </div> </a> <div class="gallery-item-description"> <p align="center">{{gridOptions.name}}</p> </div> </div> </div> </div> </div> </div>
<div ng-app="myApp" ng-controller="BasicCtrl20"> <div class="posts"> <div class="gallery"> <div ng-repeat = "gridoptions in gridOptions4"> <div class="{{gridOptions.class}}"> <div class="gallery-item"> <a href="{{gridOptions.main_href}}"> <div class="gallery-item-image"> <img ng-src="{{gridOptions.imgsrc}}"> </div> </a> <div class="gallery-item-description"> <p align="center">{{gridOptions.name}}</p> </div> </div> </div> </div> </div> </div> </div>
|

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.