Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 用于不更改旧样式值_Angular_Typescript - Fatal编程技术网

Angular 用于不更改旧样式值

Angular 用于不更改旧样式值,angular,typescript,Angular,Typescript,在我的组件html中,使用ngfor创建月份列表,并调用函数(myColDiv)设置div的类(属性),并设置宽度的变量值(一些计算) html 为什么this.prjtStartDays也不绑定到旧值,有什么问题吗 每个div都有适当的值,如10,20,30,10…120。 如何将所有div宽度设置为最后一个值(120) 如果你能提供一个plunkr就很容易了。您是否尝试过使用[ngStyle]而不是[style]?使用[style.width]=“prjtStartDays+'%'”您希望所

在我的组件html中,使用ngfor创建月份列表,并调用函数(myColDiv)设置div的类(属性),并设置宽度的变量值(一些计算)

html

为什么this.prjtStartDays也不绑定到旧值,有什么问题吗

每个div都有适当的值,如10,20,30,10…120。
如何将所有div宽度设置为最后一个值(120)

如果你能提供一个plunkr就很容易了。您是否尝试过使用[ngStyle]而不是[style]?使用[style.width]=“prjtStartDays+'%'”您希望所有列的宽度都为120%吗?是的,所有div的宽度都必须为120%。请创建一个stackblitz并在此处共享,如果您提供了一个plunkr,这将很容易。您是否尝试使用[ngStyle]而不是[style]?使用[style.width]=“prjtStartDays+'%'”是否希望所有列的宽度都为120%?是的,所有div的宽度都必须为120。请创建一个stackblitz并在此处共享
<div  *ngFor="let monthCnt of monthCounts;" >
    <div [attr.class]="myColDiv(monthCnt)">
       <div class="myEventTitleProgress" [style.width]="prjtStartDays+'%'">
         {{prjtStartDays}}
       </div>
    </div>
</div>
 myColDiv(month) {
      this.prjtStartDays = month*10;
      return "col-"+month;
    }