0

I currently use this code snippet to get the parallax effect:

ngAfterViewInit(){
  if(isBrowser) {
    $('.parallax').parallax();
  }
}

I want to know if there is another way to use the jquery plugins and not have to validate on all the components with isBrowser

1 Answer 1

0

Relevent solution.

His solution is more centered around finding out if the broswer is IE, but contains code that can also apply to you.

app.service('browser', ['$window', function($window) {

 return function() {

    var userAgent = $window.navigator.userAgent;

    var browsers = {chrome: /chrome/i, safari: /safari/i, firefox: /firefox/i, ie: /internet explorer/i};

    for(var key in browsers) {
        if (browsers[key].test(userAgent)) {
            return key;
        }
   };

   return 'unknown';
 }

}]);
Sign up to request clarification or add additional context in comments.

1 Comment

This answer seems to target AngularJS 1.x, where the OP is asking about Angular 2+ (see the tag angular-universal and ngAfterViewInit)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.