0

I have a view that is loaded on desktop in a list table which works perfect on desktop, but on mobile I need to change the display to the grid as it formats much better on mobile and looks great.

You can see the code below that assigns the "List" as the default view, but I need it to change to "Grid" on mobile devices. Can someone help me find a way to do this in an angular friendly way?

$scope.view = "List";

$scope.changeViewToList = function () {
    $scope.view = "List";
};

$scope.changeViewToGrid = function () {
    $scope.view = "Grid";
};
billy_comic
  • 867
  • 6
  • 27
  • http://stackoverflow.com/questions/16297238/angularjs-different-views-based-on-desktop-or-mobile – skubski Aug 18 '15 at 13:52

1 Answers1

0

While it's not the most elegant or "angularish" way to solve the issue, still a very easy fix.

if(window.innerWidth <= 800) {
        $scope.view = "Grid";
    } else {
        $scope.view = "List";
    }
billy_comic
  • 867
  • 6
  • 27