出于某种原因,我必须在生产模式下运行我的应用程序.这些模式有什么区别?
我正在使用Angular2 quick startdemo进行演示TypeScript.一切都运行良好,但在完成演示后,我在浏览器控制台中看到了一条消息
Angular 2正在开发模式下运行.调用enableProdMode()以启用生产模式.
import { bootstrap } from '@angular/platform-browser-dynamic';
import { AppComponent } from './app.component';
import { enableProdMode } from '@angular/core';
enableProdMode();
bootstrap(AppComponent);
Run Code Online (Sandbox Code Playgroud)
题
有人可以解释一下吗?
我想在Angular2中制作一个圆形板.例如,我想制作10个圆圈,但实际上这个数字可以改变.我想计算每个圆的半径,所以它是动态的而不是静态的.例如,参见图片
这是我的代码
@Component({
selector:"circle"
template: `
<svg>
<circle *ngFor='#item of forLength #i=index #l=last #e=even'
cx="50%" cy="50%" [style.r]="calculateRadius()" stroke="black" stroke-width="5" fill="white"></circle>
<svg/>
`
})
export class CircleComponent{
public maxRadius:number=25;
public totalRounds:number=10;
public x:number=30;
public calculateRadius():number{
var distanceBetweenCircles=this.maxRadius/(this.totalRounds-1);
this.x-= distanceBetweenCircles;
return this.x;
}
}
Run Code Online (Sandbox Code Playgroud)
但是我收到以下错误:
calculateRadius() in CircleComponent@7:30' has changed after it was checked.
Previous value: '-7.500000000000007'.
Current value: '-36.66666666666668' in [calculateRadius() in CircleComponent@7:30]
Run Code Online (Sandbox Code Playgroud)
有没有更好的方法来编写这个for循环*ngFor而不是在单独的方法中写这个?