ng-inspector icon indicating copy to clipboard operation
ng-inspector copied to clipboard

date within variable is not displayed

Open pasunboneleve opened this issue 10 years ago • 3 comments
trafficstars

It seems to me that whenever I have a JavaScript date in a scope variable, ng-inspector will display an icon for {} (object) in the right panel (Chrome 39), but when I try to open it, it will remain blank. However, if I click on the icon, it will log the date in the console. Can you confirm this bug? Is this intended behaviour?

pasunboneleve avatar Sep 24 '15 05:09 pasunboneleve

Hey @dmvianna, thanks for the report!

  • plnkr to replicate: http://plnkr.co/edit/wHjyBEHjNn70eH42L5ky?p=preview

I definitely wouldn't consider this intended behavior -- just something we haven't noticed before :)

At the moment, the following code is driving this:

// Object
else if (angular.isObject(value)) {
    this.view.setType('ngi-model-object');
    var length = Object.keys(value).length;
    if (length === 0) {
        valSpan.textContent = '{ }';
    } else {
        valSpan.textContent = '{...}';
        this.view.setIndicator(length);
    }
    this.view.makeCollapsible(true, true);
    this.update(value, depth.concat([this.value]), Model);
}

Since angular.isObject is true on Date objects, it's currently just treating Date's as POJO's.

We should probably just add an additional case for angular.isDate(value), and then render a string representation of the date.

@rev087 Interested in whipping up an icon for dates?

DrewML avatar Sep 27 '15 20:09 DrewML

@DrewML will do

rev087 avatar Sep 27 '15 22:09 rev087

Promise (#143) and Date icons added to repo.

rev087 avatar Sep 29 '15 23:09 rev087