2016-06-27 17 views
1

私は現在データ呼び出しにラムダ式を使用しています。これはChromeでうまくいきます。私はIE上でも動作させる必要があり、IEはそれらを受け入れません。私が使用していたコードは次のとおりです。ラムダ式をIEが受け入れていないので置き換えてください。

myApp.factory('User', ['$resource', 
function saveDateFactory($resource) { 
    var myData = ''; 

    //this grabs the data we need for the url below 
    function getMyData(data) { 
    myData = data; 

    } 

    //this is where we actually capture the data 
    return { 
    getMyData: getMyData, 
    resource:() => $resource(myData, {}, { 
     query: { 
     method: "GET", params: {}, isArray: true, 
     interceptor: { 
      response: function (response) { 
      //this is the piece we actually need 
      return response.data; 
      } 
     } 
     } 
    }) 
    }; 
}]); 

誰もがIEはそれを受け入れるだろうと、それはまだ動作しますので、私はこれを変更する方法についての提案を持っていますか?ご協力いただきありがとうございます!

+0

のように通訳なしでこのES6機能を使用しないことをお勧め

.... IEのための空席がありませんにテスト? –

+0

私の答えはあなたを助けましたか?もしそうなら、投票して正解と記入してください。 –

答えて

3

IE互換性は、ES6 hereで確認できます。この() =>機能はExpressionBodiesと呼ばれ、それは、私はあなたがしているIEのバージョンBabelJs

myApp.factory('User', ['$resource', 
function saveDateFactory($resource) { 
    var myData = ''; 

    //this grabs the data we need for the url below 
    function getMyData(data) { 
    myData = data; 
    } 

    //this is where we actually capture the data 
    return { 
    getMyData: getMyData, 
    resource: function(){ 
     $resource(myData, {}, { 
     query: { 
      method: "GET", params: {}, isArray: true, 
      interceptor: { 
      response: function (response) { 
       //this is the piece we actually need 
       return response.data; 
      } 
      } 
     } 
     }); 
    } 
    }; 
}]); 
関連する問題