2016-06-27 20 views
1

我目前在我的數據調用中使用lambda表達式,它在Chrome上效果很好。我必須讓它在IE上工作,IE也不會接受它們。我正在使用的代碼是:替換lambda表達式,因爲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

你是哪個版本的IE測試? –

+0

我的回答對你有幫助嗎?如果是這樣,你可以請投票並標記爲正確的答案? –

回答

3

您可以檢查ES6 here的IE兼容性。這() =>功能稱爲ExpressionBodies和它不適用於IE ....

我建議你不要使用此ES6功能沒有翻譯像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; 
      } 
      } 
     } 
     }); 
    } 
    }; 
}]); 
相關問題