AngularJS和IE 8服务错误 [英] AngularJS and IE 8 errors on services

查看:34
本文介绍了AngularJS和IE 8服务错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在IE 8或更高版本上部署AngularJS 1.5.1.

I'm trying to deploy my AngularJS 1.5.1 on IE version 8 or Higher.

该应用在第一次尝试时就崩溃了,我的所有js服务都出现了很多错误,均出现以下错误:

The app was crached in the first attempt and i got many errors for all my js services all with the error:

SCRIPT1003:':'参加

SCRIPT1003: ':' attendu

示例:

var servcModule = angular.module('myApp.services',[]);

servcModule.factory('NameService', function(Restangular,$http) {

            var list=null;


            var getList = function(Key){

                var result = $http({
                    method: 'POST', url:'NameService/getList',
                    data: Key
                }).then(function (response) {
                    return response.data;
                });
                return result;

            }


            var getListPersone = function(){
                var listPersone = Restangular.all('NameService/getListPersone');
                return listPersone.getList().$object;
            }


    return {
        getList, // here the error
        getListPersone
        };
    } );

在"return {"之后,在"getList"行中指出的错误,对于在"return {"之后的另一行,也存在相同的错误

The error pointed in line "getList," after "return {", and also for the other the same error in the line just after "return {"

推荐答案

IE8(通常是IE/Edge)当然不支持此ES6语法糖:

IE8 (And IE/Edge in general) certainly doesn't support this ES6 syntactic sugar :

return {
        getList, // here the error
        getListPersone
};

使用旧的ES5:

return {
        getList : getList,
        getListPersone :getListPersone
};

这篇关于AngularJS和IE 8服务错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆