2016-06-21 11 views
0

AngularJSアプリケーション(バージョン:1.4.10)をビルドしていますが、最近Safariでしかアプリケーションが動作しないことがわかりました。私が手AngularJS:Safariでモジュールをロードできませんでした

エラーは次のとおりです。

[Error] SyntaxError: Unexpected token '<' (anonymous function) (angular-slide.js:1) 
[Error] SyntaxError: Unexpected token '>' (anonymous function) (landing.js:132) 
Error: [$injector:modulerr] Failed to instantiate module myApp due to: 
[$injector:modulerr] Failed to instantiate module myApp.landing due to: 
[$injector:nomod] Module 'myApp.landing' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument. (angular.js:4496) 

これはSafariのみで起こります。 FirefoxとChromeで私は、コンソールからこのメッセージが表示されます:

scope.$watch(attrs.slider, (n, o) => { 

ディレクティブの全体のコードは以下の通りです:

angular-slide.js:1 Uncaught SyntaxError: Unexpected token < 

ラインlanding.jsの132は、以下のとおりです。

}]).directive('slider', function() { 
    return { 
     restrict:'A', 
     compile: function (element) { 
      // wrap tag 
      var contents = element.html(); 
      element.html('<div class="slideable_content" style=" margin:0 !important; padding:0 !important; height: 300px;" >' + contents + '</div>'); 

      return function postLink(scope, element, attrs) { 
       var i = 0; 
       // default properties 
       scope.$watch(attrs.slider, (n, o) => { 
        if (n !== o) { 
         i++; 
         var target = element[0], 
          content = target.querySelector('.slideable_content'); 
         if(n) { 
          content.style.border = '1px solid rgba(0,0,0,0)'; 
          var y = content.clientHeight, z = i; 
          content.style.border = 0; 
          target.style.height = y + 'px'; 
          setTimeout(() => { 
           if (z === i) { 
            target.style.height = 'auto'; 
           } 
          }, 500); 
         } else { 
          target.style.height = target.clientHeight + 'px'; 
          setTimeout(() => { 
           target.style.height = '0px'; 
          }); 
         } 
        } 
       }); 

       attrs.duration = (!attrs.duration) ? '0.5s' : attrs.duration; 
       attrs.easing = (!attrs.easing) ? 'ease-in-out' : attrs.easing; 
       element.css({ 
        'overflow': 'hidden', 
        'height': '0px', 
        'transitionProperty': 'height', 
        'transitionDuration': attrs.duration, 
        'transitionTimingFunction': attrs.easing 
       }); 
      }; 
     } 
    }; 
}); 

は、どのように私はこのディレクティブSafariの準拠を作成し、エラーを修正することができますか?

答えて

0

[ほとんどの]ブラウザはes6ラムダをサポートしていません。 Babelのようなツールを使ってes6をes5に置き換える必要があります。すなわち

(n, o) => {...}のES5当量function(n, o) {...}あります。

関連する問題