简体   繁体   English

如何更改Mobile Angular JS上的默认单选按钮

[英]How Can I Change Default Radio Button On Mobile Angular JS

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";
};

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";
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM