
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
angular-matchmedia
Advanced tools
Angular-matchmedia service is a set of bindings and helper functions for the browser matchMedia api.
This service is a set of bindings and helper functions for the browser matchMedia api. It allows you to check any media query right in your AngularJS application. It has one core method check
and few helper shortcuts (see examples below). Also, you can configure service rules
on config stage of your AngularJS app.
npm
$ npm install --save-dev angular-matchmedia
or you can download archive on Releases
page.
After that just include dist/angular-matchmedia.js
file in your application (between main AngularJS library and your app js file).
Method allows you to check any media query right in your controller or service. You should pass just one parameter: any media query. Methods returns true
or false
depending on media query result.
app.controller('MainCtrl', function($scope, matchMedia) {
$scope.isThisIphone6 = matchMedia.check('only screen and (min-device-width: 375px) and (max-device-width: 667px) and (-webkit-min-device-pixel-ratio: 2) and (orientation: portrait)');
});
Method allows you to check if your application is viewed on mobile device (according to the following default media query rule: (max-width: 767px)
).
app.controller('MainCtrl', function($scope, matchMedia) {
$scope.isThisIphone6 = matchMedia.check('only screen and (min-device-width: 375px) and (max-device-width: 667px) and (-webkit-min-device-pixel-ratio: 2) and (orientation: portrait)');
});
Method allows you to check if your application is viewed on tablet (according to the following default media query rule: (min-width: 768px) and (max-width: 1024px)
).
app.controller('MainCtrl', function($scope, matchMedia) {
$scope.isThisIphone6 = matchMedia.check('only screen and (min-device-width: 375px) and (max-device-width: 667px) and (-webkit-min-device-pixel-ratio: 2) and (orientation: portrait)');
});
Method allows you to check if your application is viewed on desktop (according to the following default media query rule: (min-width: 1025px)
).
app.controller('MainCtrl', function($scope, matchMedia) {
$scope.isThisIphone6 = matchMedia.check('only screen and (min-device-width: 375px) and (max-device-width: 667px) and (-webkit-min-device-pixel-ratio: 2) and (orientation: portrait)');
});
Method allows you to check if your application is viewed on device with portrait orientation (according to the following default media query rule: (orientation: portrait)
).
app.controller('MainCtrl', function($scope, matchMedia) {
$scope.isThisIphone6 = matchMedia.check('only screen and (min-device-width: 375px) and (max-device-width: 667px) and (-webkit-min-device-pixel-ratio: 2) and (orientation: portrait)');
});
Method allows you to check if your application is viewed on device with landscape orientation (according to the following default media query rule: (orientation: landscape)
).
app.controller('MainCtrl', function($scope, matchMedia) {
$scope.isThisIphone6 = matchMedia.check('only screen and (min-device-width: 375px) and (max-device-width: 667px) and (-webkit-min-device-pixel-ratio: 2) and (orientation: portrait)');
});
Method allows you to check if your application is viewed on retina device (according to the following default media query rule: (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi)
).
app.controller('MainCtrl', function($scope, matchMedia) {
$scope.isThisIphone6 = matchMedia.check('only screen and (min-device-width: 375px) and (max-device-width: 667px) and (-webkit-min-device-pixel-ratio: 2) and (orientation: portrait)');
});
You can check live demo of this service on Plunker.
// add dependency to your application
var app = angular.module('application', ['angular-matchmedia']);
// you can change default `rules` of the service (set your own breakpoints) in your app config
app.config(["matchMediaProvider", function(matchMediaProvider) {
matchMediaProvider.rules.phone = '(max-width: 767px)';
matchMediaProvider.rules.tablet = '(min-width: 768px) and (max-width: 988px)';
}]);
// inject service into your controller and you are ready to go
app.controller('MainCtrl', function($scope, matchMedia) {
$scope.isTablet = matchMedia.isTablet();
$scope.isRetina = matchMedia.isRetina();
});
rules = {
phone: '(max-width: 767px)',
tablet: '(min-width: 768px) and (max-width: 1024px)',
desktop: '(min-width: 1025px)',
portrait: '(orientation: portrait)',
landscape: '(orientation: landscape)',
retina: '(-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi)'
}
MIT © Sergey Lysenko
FAQs
Angular-matchmedia service is a set of bindings and helper functions for the browser matchMedia api.
The npm package angular-matchmedia receives a total of 93 weekly downloads. As such, angular-matchmedia popularity was classified as not popular.
We found that angular-matchmedia demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.