0
<progress-bar [value]="currentProgressValue" [max]="currentProgressMaxValue" [title]="currentTaskName"></progress-bar>

If I use it like

<progress-bar [value]="30" [max]="100" [title]="abc"></progress-bar>

It works, but if I use the above it doesnt.

Edit: I'm using this package :https://github.com/pleerock/ngx-progress-bar/blob/master/src/index.ts

I have this code in my view,

here's my viewmodel

@Output() public currentProgressValue: number
@Output() public currentProgressMaxValue: number
@Output() public currentTaskName: string


pushTask(maxValue: number, isIndeterminate: boolean = true, taskName: string) {

    var token = new ProgressToken(maxValue, isIndeterminate, taskName);

    token.subscribe((x) => {
        if (this.currentToken == null || this.currentToken == token) {
            this.currentProgressValue = x;
            this.currentProgressMaxValue = token.maxValue;
            this.currentTaskName = token.taskName;
            console.log(this.currentProgressValue)
        }

        if ((this.currentToken == token && x >= token.maxValue)) {
            this.activeTasks = this.activeTasks.filter((x) => x != token);
            var nextTask = this.activeTasks.find(x => x != null);
            if (nextTask != null) {
                this.isCurrentProgressIndeterminate = nextTask.isIndeterminate;
                this.currentProgressMaxValue = token.maxValue;
                this.currentProgressValue = x;
                this.currentToken = nextTask;
            }
        }
    });

    this.activeTasks.push(token);

    return token;
}

I see that the properties change if I debug them but the UI doesnt update. What am I doing wrong?

Here's the code I use to test it :

ngOnInit() {
    if (isBrowser) {
        this.progressToken = this.progress.pushTask(100, true, "Doing work");
        var prog = 0;
        let timer = TimerObservable.create(2000, 1000);

        this.subscription = timer.subscribe(t => {
            this.progressToken.next(this.v)
            this.v = this.v + 1;
        });

    }
}


import { Subject } from 'rxjs/Subject'
import 'rxjs/Rx';


export class ProgressToken extends Subject<number> {

    isIndeterminate: boolean
    currentValue: number
    maxValue: number
    taskName: string

    constructor(maximumValue: number, isIndeterminate: boolean, currentTaskName: string) {
        super();
        this.taskName = currentTaskName;
        this.maxValue = maximumValue;
        this.isIndeterminate = isIndeterminate;
    }


}

Here's how I import my component :

import { ProgressComponent } from '../progress/progress.component'

@Component({
    selector: 'login-component',
    templateUrl: './login.component.html',
    providers: [ProgressComponent]
})

And ProgressComponent is marked with Injectable(), then use it in the constructor as

private progress: ProgressComponent

Referring to this answer : https://stackoverflow.com/a/39801791/4487530

Community
  • 1
  • 1
Christo S. Christov
  • 2,268
  • 3
  • 32
  • 57

0 Answers0