#How to communicate values with in the html template form for loop to separate div ?

10 messages · Page 1 of 1 (latest)

ashen rose
#
  • Trying to get the a value from for loop [hits.length ]
  • This [htis.length] will change.
  • Wanted to use it out side for the for loop<div>?
ashen rose
#
  selector: 'infinite-scroll',
  template: 
    <div class="container">
  <ais-instantsearch [config]="config">
    <div class="search-panel">
      <div class="search-panel__results">
        <div class="searchbox">
          <ais-search-box placeholder=""></ais-search-box>
        </div>
        
        <ais-stats>
        <ng-template let-state="state">{{'hit.length'}}
          {{state.nbHits}} results .
        </ng-template>
      </ais-stats>

        <ais-infinite-hits>
          <ng-template
            let-hits="hits"
            let-results="results"
            let-refine="showMore"
          >
          <h2>this value of length {{hits.length}}</h2>
            <div *ngIf="hits.length === 0">No results found.</div>

            <ol class="ais-Hits-list">
              <li class="ais-Hits-item" *ngFor="let hit of hits">
                <ais-highlight attribute="name" [hit]="hit"></ais-highlight>
              </li>
              <div (onVisible)="refine()"></div>
            </ol>
            <ol class="ais-Hits-list">
              <li class="ais-Hits-item" *ngFor="let result of results">
                <ais-highlight attribute="name" [hit]="result"></ais-highlight>
              </li>
              <div (onVisible)="refine()"></div>
            </ol>
          </ng-template>
        </ais-infinite-hits>
      </div>
    </div>
  </ais-instantsearch>
</div> ```
stark condor
#

g!badeyes @ashen rose

nimble craneBOT
#

@ashen rose Please do not post pictures of code (especially photos of a physical screen) as they are difficult to read and difficult to correct (as you cannot copy code from a screenshot to modify it).

stark condor
#

g!codeblock @ashen rose

nimble craneBOT
#

@ashen rose, you can use the following snippet to have your code formatted and colored by Discord. Replace ts with the language you need (i.e. html, js, css, etc)
```ts
// your code goes here
```

stark condor
#

And check that typo in html interpolation hits.lenth instead of hits.length

ashen rose
#

@stark condor typo is corrected . but not working .