Progress
<Progress>
is a UI component that shows a bar to indicate the progress of a task.
See also: ActivityIndicator
Example
Example: Simple Progress
<progress value="25" maxValue="100" (valueChanged)="onValueChanged($event)"></progress>
import { Component, OnInit } from '@angular/core'
@Component({
moduleId: module.id,
templateUrl: './styling.component.html',
styleUrls: ['./styling.component.css']
})
export class StylingComponent implements OnInit {
public progressValue: number
ngOnInit() {
this.progressValue = 25
}
}
<Progress
width="100%"
value="{{ progressValue }}"
maxValue="{{ progressMaxValue }}"
loaded="onProgressLoaded"
/>
import { Observable, Page, Progress, PropertyChangeData } from '@nativescript/core'
export function onNavigatingTo(args) {
const page = args.object as Page
const vm = new Observable()
vm.set('progressValue', 10) // Initial value
vm.set('progressMaxValue', 100) // Maximum value
// Forcing progress value change (for demonstration)
setInterval(() => {
const value = vm.get('progressValue')
vm.set('progressValue', value + 2)
}, 300)
page.bindingContext = vm
}
export function onProgressLoaded(args) {
const myProgressBar = args.object as Progress
myProgressBar.on('valueChange', (pargs: PropertyChangeData) => {
// TIP: args (for valueChange of Progress) is extending EventData with oldValue & value parameters
console.log(`Old Value: ${pargs.oldValue}`)
console.log(`New Value: ${pargs.value}`)
})
}
function getTaskCompletionPercent() {
// Just a stub method to illustrate the concept.
return 10
}
;<progress value={getTaskCompletionPercent()} maxValue={100} />
<progress :value="currentProgress" />
<progress value="{currentProgress}" />
Props
Name | Type | Description |
---|---|---|
|
|
Gets or sets the current value of the progress bar.
Must be within the range of 0 to |
|
|
Gets or sets the maximum value of the progress bar.
+ Default value: |
|
|
Additional inherited properties not shown. Refer to the API Reference |