Progress 进度条:
- value当前值
- maxValue 最大值
下面的代码还用了下 propertyChangeimport {Component, ViewChild, ElementRef} from "angular2/core";
import {Color} from "color";
import {SearchBar} from "ui/search-bar";
import {TextField} from "ui/text-field";
import {Switch} from "ui/switch";
import {Slider} from "ui/slider";
import {Progress}from"ui/progress";
import {PropertyChangeData} from "data/observable";
@Component({
selector: "my-app",
template: `
<StackLayout orientation="vertical">
<Progress #sw style="color:red" [value]="value" maxValue="300" ></Progress>
<Button text="add" (tap)="btn()"></Button>
</StackLayout>
`,
styleUrls: ["app.css"]
})
export class AppComponent {
@ViewChild('sw') ngProgress: ElementRef;
nsProgress: Progress;
value: Number = 60;
constructor() {
}
ngAfterViewInit() {
this.nsProgress = this.ngProgress.nativeElement;
this.nsProgress.on("propertyChange", (e: PropertyChangeData) => {
console.log(e.propertyName);
})
}
btn() {
this.nsProgress.maxValue = 200;
}
}
这个主要代码:<Progress #sw style="color:red" [value]="value" maxValue="300" ></Progress>
maxValue小于value的时候会有两个propertyChange事件,因为value也跟着变小了
并且这个组件不能用ngModel,因为不是input组件