Ember cli Uncaught TypeError:undefined不是函数

时间:2015-03-13 22:30:33

标签: javascript ember.js firebase ember-cli ember-cli-addons

我是一个余烬noob,我最初构建我的应用程序没有ember-cli它工作正常 然后我明白了用ember-cli重建我非常简单的应用程序,这可能会出错:)

两个应用程序中的一切都一样,直到ember抛出错误并指向我的诗歌控制器第52行,请记住这个文件在我的非ember-cli版本中完全相同

更新我只是在第52行放置了很多空格,现在它说错误在第53行是空的:(((

import Ember from 'ember';

export default Ember.Controller.extend({
    sortProperties:["time"],
    sortAscending:true,
    start:new Date(),
    count:0,
    incorrect:0,
    startReview:true,
    showHighScores:false,

    actions:{

        startReview:function(){
            this.set('startReview',false);
            this.set("showHighScores",false);
            this.start = new Date();
            this.count = 0;
            this.incorrect = 0;
            console.log(this.count);
        },

        showHighScores:function(){
            this.toggleProperty("showHighScores");
        },

        checkCorrectness:function(word){
            var textArray = this.get("model.text").split(" ");
            var length = textArray.length;
            console.log(this.array);
            if(word === textArray[this.count]){

                console.log("correct");
                this.count++;
                console.log(this.count);
            }else{
                console.log("Incorrect");
                this.incorrect++;
            }
            if(length === this.count){
                var finish = new Date();
                var time = finish-this.start;
                var accuracy = (this.count/(this.count+this.incorrect)*100);
                alert("You took "+time/1000+" seconds! With "+accuracy+"% accuracy!");
                this.saveResult(time);
                this.set('startReview',true);
            }
        },
    },
    randomizer:function(){
        this.set("randomArray",this.get("model.text").split(" ").randomize());      
    **}.observes("startReview"),**//The offending line

    saveResult:function(timeTaken){
        var date = new Date(),
            userName = "TimTheGreat";


        var score = this.store.createRecord('score',{
            userName:userName,
            date:date,
            time:timeTaken,
            verse:this.get('model'),
        });

        var controller = this;
        var scores = controller.get("model.scores");
        score.save().then(function(score){
            scores.addObject(score).then(function(){
                controller.get("model").save();
            });

        });
    }
});

1 个答案:

答案 0 :(得分:0)

违规行实际上是前一行。

this.set("randomArray",this.get("model.text").split(" ").randomize());

无论是在Ember还是在原生javascript中,数组都没有randomize方法。这可能是您或之前添加的其他lib。