我如何在CSS网格中插入角分量

发布于 2025-02-13 21:01:19 字数 1084 浏览 0 评论 0原文

我正在学习Angular,并且正在从事一个项目,其中我需要使用CSS网格布局。但是,我试图找到一种用给定的网格区域在网格中插入组件的方法。

我试图这样做,< app-slots></app-slots>,在app.component.ponent.html中插槽> 仅被计为一个网格位。即使这是42个地方。

slots.component.html:

< div class =“ abc” *ngfor =“让getarrayofnumbers(42);让i = index“ [style.grid-row] =” i+1“样式=”高度:20px“> {{in}}</div>

slots.component.ts:

   import { Component, OnInit } from '@angular/core';
    
    @Component({
      selector: 'app-slots',
      templateUrl: './slots.component.html',
      styleUrls: ['../../app.component.css']
    })
    export class SlotsComponent implements OnInit {
    
      constructor() { }
    
      ngOnInit(): void {
        
      }
    
      getArrayOfNumbers(x: number){
        var slots:number[] = [];
        var a: number = x;
        
        while(x != 0){
          slots.push(x);
          x--;
        }
        return slots;
      }
    
    }

注意:如果不清楚某些内容

I'm learning Angular, and I'm working on a project ,in which, I need to use a CSS grid layout. However, I'm trying to find a way to insert a component inside a grid with given grid-area.

I tried to do this, <app-slots></app-slots>, in app.component.html but the component <app-slots> was counted as one grid place only; even though, it's 42 places.

slots.component.html:

<div class="abc" *ngFor="let in of getArrayOfNumbers(42) ;let i = index" [style.grid-row] = "i+1" style = "height:20px" > {{in}} </div>

slots.component.ts:

   import { Component, OnInit } from '@angular/core';
    
    @Component({
      selector: 'app-slots',
      templateUrl: './slots.component.html',
      styleUrls: ['../../app.component.css']
    })
    export class SlotsComponent implements OnInit {
    
      constructor() { }
    
      ngOnInit(): void {
        
      }
    
      getArrayOfNumbers(x: number){
        var slots:number[] = [];
        var a: number = x;
        
        while(x != 0){
          slots.push(x);
          x--;
        }
        return slots;
      }
    
    }

Note: If something is not clear please tell me to add more info

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

羁拥 2025-02-20 21:01:19

您可以只插入标签之间的组件(而不是{{{in}}),然后使用Angular的绑定功能通过该功能发送来自.ts文件的任何更新变量?

两种绑定

can you just insert the component between your tags (instead of {{in}}), then send whatever updating variables from the .ts file through that using angular's binding feature ?

two way binding

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文