user2024080
user2024080

Reputation: 5101

How to console my ember models as json values?

I would like to console all my model's current satus before i proceed to next router. for that, I am trying to check the status of my model. I tried like this form the suggession of this quesiton:Ember model to json

import Ember from 'ember';

export default Ember.Controller.extend({
    actions: {
        proceed: function() {
            this.set('clickCancel',false);
        },

        formValidateBeforeNext:function(){
            console.log("i am called", this.getProperties(ret) );
        }
    }
});

But not works!!

UPDATE:

I tried to console models as this way still not works.

import Ember from 'ember';

export default Ember.Controller.extend({
    actions: {
        proceed: function() {
            this.set('clickCancel',false);
        },

        formValidateBeforeNext:function(){
            var rect = {};
            var propertyNames = arguments;
            if (arguments.length === 1 && Ember.typeOf(arguments[0]) === 'array') {
                propertyNames = arguments[0];
            }

             for(var i = 0; i < propertyNames.length; i++) {
                ret[propertyNames[i]] = get(this, propertyNames[i]);
            }

            console.log( "rect is",  rect );
        }
    }
});

Upvotes: 0

Views: 65

Answers (1)

Martin Heon
Martin Heon

Reputation: 44

I see a typo in your example... ret[propertyNames[i]] = get(this, propertyNames[i]); should be ... rect[propertyNames[i]] = get(this, propertyNames[i]);

Upvotes: 1

Related Questions