Giter Site home page Giter Site logo

manucutillas / ngx-responsive Goto Github PK

View Code? Open in Web Editor NEW
299.0 18.0 70.0 2.35 MB

Superset of RESPONSIVE DIRECTIVES to show or hide items according to the size of the device screen and another features in Angular 9

License: MIT License

TypeScript 100.00%
angular angular-2 responsive progressive-web-app progressive pwa angular5 rxjs bootstrap ngx

ngx-responsive's Introduction

DEPRECATED LIBRARY - no longer actively maintained.

ngx-responsive

Introduction

Superset of RESPONSIVE DIRECTIVES to show or hide items according to the size of the device screen and another features in Angular 9.

npm i ngx-responsive --save

If you use Angular 8 in your project.

npm i [email protected] --save

If you use Angular 7 in your project.

npm i [email protected] --save

If you use Angular 6 in your project.

npm i [email protected] --save

If you use Angular 5 in your project.

npm i [email protected] --save

If you use Angular 4 in your project use ng2-responsive.

npm i ng2-responsive --save

RESPONSIVE_DIRECTIVES provides the following features:

  • Directives detecting states according to standard measures in BOOTSTRAP: xs / sm / md / lg / xl
  • Directives that detect four states according to the real type of device: mobile / tablet / desktop / smartTv
  • Custom sizes detector.
  • Show and hide options.
  • Custom breaking points.
  • Debounce checking interval (default 100ms).
  • Browsers Detect: Chrome / Safari / Firefox / IE / Opera
  • Internet Explorer Versions Detect : IE 9 / IE 10 / IE 11 / IE +12
  • New standard devices: iPhone, iPad, Android Mobile, Android Tablet, Windows Phone.
  • Device orientation detect: portrait, landscape.
  • Directives Info: DeviceInfo, OrientationInfo, ResponsiveSizeInfo, DeviceStandardInfo, BrowserInfo, IeInfo.
  • Directive: responsive - Detection of multiple functions at once.
  • Feature Responsive Directive - Boolean Events Emitter on change state:
  • Feature responsive-window : Capture the size of the parent element to show or hide fill elements. If the parent responsive size is x show or hide.
  • UserAgent information directive: Get te device, browser, os version and more from the user agent navigator in one event object.
  • New Feature : Reactive services that expose changes through observables:
    • BrowserInfoRx
    • IeInfoRx
    • DeviceInfoRx
    • DeviceStandardInfoRx
    • OrientationInfoRx
    • ResponsiveSizeInfoRx
    • UserAgentInfoRx

How to start

1. Installing the package via npm

npm i ngx-responsive --save

2. Bootstrap the service

  • With default breaking points

import { NgModule } from '@angular/core'
import { ResponsiveModule } from 'ngx-responsive'
...
@NgModule({
    imports: [
      ResponsiveModule.forRoot()
    ],
    declarations: [
      AppComponent
    ],
    providers:[]
})
export class AppModule { }
  • With custom Configuration

  import { NgModule } from '@angular/core'
  import { ResponsiveModule } from 'ngx-responsive'
  ...
  const config = {
    breakPoints: {
        xs: {max: 600},
        sm: {min: 601, max: 959},
        md: {min: 960, max: 1279},
        lg: {min: 1280, max: 1919},
        xl: {min: 1920}
    },
    debounceTime: 100
  };
  ...
@NgModule({
    imports: [
      BrowserModule,
      ResponsiveModule.forRoot(config)
    ],
    declarations: [
      AppComponent
    ],
    providers:[]
})
export class AppModule { }

2.1 DIRECTIVES:

In your component to import the RESPONSIVE_DIRECTIVES only need import:

@Component({
  selector: 'my-component',
  template: `
    <p *showItStandard="['iphone','ipad']">I'll show you if I'm a iPhone or ipad device.</p>
    <p *isIphone>I'll show you if I'm a iPhone device.</p>
    <p *isChrome>I'll show you if I'm a chrome browser.</p>
    <p *xl>I'll show you if I'm a xl screen size.</p>
    <p *lg>I'll show you if I'm a lg screen size.</p>
    <p *md>I'll show you if I'm a md screen size.</p>
    <p *sm>I'll show you if I'm a sm screen size.</p>
    <p *xs>I'll show you if I'm a xs screen size.</p>
  `
})

3. ALL RESPONSIVE DIRECTIVES OPTIONS

  • 3.1 Responsive Window directive.

    Capture the size of the parent element to show or hide fill elements. If the parent responsive size is x show or hide.

    3.1.1 First syntax

    Define a named parrent element, the reference is stored on the service and available outside of the current container. Name must be unique to avoid conflicts

    <div [responsive-window]="'parent'">
        <p *responsive="{ sizes:{  window: 'parent', min:900, max:1400} }">...</p>
    </div>

    3.1.2 Second syntax

    Define a reference to the parent element

      <div responsive-window #myContainerRef="container">
          <p *responsive="{ sizes: { min:900, max:1400 } } ; container:myContainerRef">...</p>
      </div>

    Or:

    <div responsive-window #myContainerRef="container">
      <ng-template [responsive]="{ sizes:{ min:900, max:1400 } }" [responsiveContainer]="myContainerRef">
          <p>....</p>
      </ng-template>
    </div>
  • 3.2 New Detection of multiple functions at once.

    All combinations

      *responsive="{
        bootstrap: ['xl','lg','md','sm','xs'],
        browser: ['chrome','firefox','ie','safari', 'opera'],
        ie:['ie 9','ie 10','ie 11','ie +12'],
        pixelratio:['1x','retina','4k'],
        standard:['iphone','ipad','android mobile','android tablet','windows phone'],
        orientation:['landscape','portrait'],
        device: ['mobile','tablet','smarttv','desktop'],
        sizes:{min:900,max:1400}
      }"

    *Example in component

    @Component({
      selector: 'my-component',
      template: `
        <p  *responsive="{
                        bootstrap: 'lg',
                        browser: ['chrome','firefox'],
                        pixelratio:'1x',
                        orientation:'landscape',
                        device: 'desktop',
                        sizes:{min:900,max:1400}
          }">I'll show you if all the options are true.</p>
    
          <template  [responsive]="{
                        bootstrap: 'lg',
                        browser: ['chrome','firefox'],
                        pixelratio:'1x',
                        orientation:'landscape',
                        device: 'desktop',
                        sizes:{min:900,max:1400}
          }" (changes)="miMethod($event)">I'll show you if all the options are true & listen events changes.</template>
      `
      })
  • 3.3 One function detect

    • With Bootstrap Screen sizes

      @Component({
        selector: 'my-component',
        template: `
          <p *xl>I'll show you if I'm a xl screen size.</p>
          <p *lg>I'll show you if I'm a lg screen size.</p>
          <p *md>I'll show you if I'm a md screen size.</p>
          <p *sm>I'll show you if I'm a sm screen size.</p>
          <p *xs>I'll show you if I'm a xs screen size.</p>
        `
        })
    • With multiple combinations of bootstrap screen sizes and show / hide options

      • Strings Multiple combinations = "['xs','sm','md','lg','xl']"

        @Component({
            selector: 'my-component',
            template: `
              <p *showItBootstrap="['md','xs']">I'll show you only in md and xs screen sizes.</p>
              <p *hideItBootstrap="['lg','sm']">I'll hide you only in lg and sm screen sizes.</p>
            `
        })
        • With Devices Screen sizes

        @Component({
              selector: 'my-component',
              template: `
                <p *isSmartTv>I'll show you if I'm a smartTv device.</p>
                <p *isDesktop>I'll show you if I'm a desktop device.</p>
                <p *isTablet>I'll show you if I'm a tablet device.</p>
                <p *isMobile>I'll show you if I'm a mobile device.</p>
              `
        })
    • With multiple devices detect combinations: show / hide options.

      • Strings Multiple combinations = "['mobile','tablet','smarttv','desktop']"

        @Component({
            selector: 'my-component',
            template: `
              <p *showItDevice="['mobile','tablet']">I'll show you if I'm a tablet or a mobile device.</p>
              <p *hideItDevice="['mobile','tablet','desktop']">I'll hide you if I'm a desktop / tablet or mobile device.</p>
            `
        })
        • With Standard Devices detect

          @Component({
              selector: 'my-component',
              template: `
                <p *isIphone>I'll show you if I'm a iPhone device.</p>
                <p *isIpad>I'll show you if I'm a iPad device.</p>
                <p *isAndroidMobile>I'll show you if I'm a android mobile device.</p>
                <p *isAndroidTablet>I'll show you if I'm a android tablet device.</p>
                <p *isWindowsPhone>I'll show you if I'm a windows phone mobile device.</p>
              `
            })
    • With multiple devices detect combinations: show / hide options.

      • Strings Multiple combinations = "['iphone','ipad','android mobile','android tablet','windows phone']"

        @Component({
            selector: 'my-component',
            template: `
              <p *showItStandard="['android mobile','windows phone']">I'll show you if I'm a android mobile or a windows phone device.</p>
              <p *hideItStandard="['iphone','ipad']">I'll hide you if I'm a iPad or a iPhone device.</p>
            `
        })
        • With orientation device

        @Component({
            selector: 'my-component',
            template: `
              <p *isPortrait>I'll show you if I'm a portrait state.</p>
              <p *isLandscape>I'll show you if I'm a landscape state.</p>
            `
        })
        • With custom sizes and show / hide options

        @Component({
            selector: 'my-component',
            template: `
              <p *showItSizes="{min:955,max:1057}">I'll show you if responsive-window width is between the min and max.</p>
              <p *showItSizes="{min:750}">I'll show you if responsive-window width is greater than or equal to min.</p>
              <p *hideItSizes="{min:360,max:768}">It is hidden if responsive-window width between the min and max.</p>
            `
        })
    • Responsive-window being window by default or any element set using the Responsive Window directive.

      • With browser detection.

        @Component({
            selector: 'my-component',
            template: `
              <p *isChrome>I'll show you if I'm a Chrome Browser.</p>
              <p *isFirefox>I'll show you if I'm a Firefox Browser.</p>
              <p *isSafari>I'll show you if I'm a Safari Browser.</p>
              <p *isOpera>I'll show you if I'm a Opera Browser.</p>
              <p *isIE>I'll show you if I'm a Internet Explorer Browser.</p>
            `
        })
        • With multiple browsers detect combinations: show / hide options.

          • Strings Multiple combinations = "['chrome','firefox','ie','safari', 'opera']"

          @Component({
            selector: 'my-component',
            template: `
              <p *showItBrowser="['ie','opera']">I'll show you if I'm a IE or Opera Browser.</p>
              <p *hideItBrowser="['chrome','firefox','safari']">I'll hide you if I'm a Chrome, Firefox or Safari Browser.</p>
            `
          })
          • With Internet Explorer Version detection.

          @Component({
            selector: 'my-component',
            template: `
              <p *isIE9>I'll show you if I'm a Internet Explorer 9.</p>
              <p *isIE10>I'll show you if I'm a Internet Explorer 10.</p>
              <p *isIE11>I'll show you if I'm a Internet Explorer 11.</p>
              <p *isIE12>I'll show you if I'm a Internet Explorer 12.</p>
            `
          })
        • With multiple Internet Explorer version detect: show / hide options.

          • Strings Multiple combinations = "['ie 9','ie 10','ie 11','ie +12']"

          @Component({
            selector: 'my-component',
            template: `
              <p *showIEVersion="['ie 11','ie +12']">I'll show you if I'm a IE 11 browser or IE 12</p>
              <p *hideIEVersion="['ie 9','ie 10']">I'll hide you if I'm IE 9 browser or IE 10.</p>
            `
          })
        • Get the userAgent info directive:

          Get the device, browser, os version and more from the user agent navigator in one event object.

          <user-agent-info (info)="thisUserAgent($event)"></user-agent-info>

4. FORMAT OF USER AGENT INFO OBJECT

Description of the object given by the (info) event of the directive user-agent-info (usage: <user-agent-info (info)="thisUserAgent($event)"></user-agent-info>).

{
  device: 'mobile' | 'tablet' | 'smarttv' | 'desktop',
  browser: 'chrome' | 'firefox' | 'ie' | 'safari' | 'opera' | 'silk' | 'yandex' | 'NA',
  pixelratio:  '4k' | 'retina' | '1x',
  ie_version: {
      name: 'ie 7' | 'ie 8' | 'ie 9' | 'ie 10' | 'ie 11' | 'ie +12',
      state: true | false
  },
  game_device: {
      name:  'Playstation 4' | 'Playstation 3' | 'Xbox one' | 'Xbox' | 'Wii' | 'Wii U' | 'Nintendo 3DS' | 'Playstation Vita' | 'PSP'
      state: true | false
  },
  smart_tv: {
      name:  'Chromecast' | 'Apple tv' | 'Google tv' | 'Xbox One' | 'Playstation 4' | 'Generic smartv'
      state: true | false
  },
  desktop: {
      name:  'Windows' | 'Mac' | 'Linux',
      state: true | false
  },
  tablet: {
      name:  'Ipad' | 'Android' | 'Kindle' | 'Generic Tablet',
      state: true | false
  },
  mobile: {
      name:  'Iphone' | 'Android' |  'Windows Phone' | 'Blackberry' | 'Generic Mobile'
      state: true | false
  },
  window_os: {
      name:  'Windows XP' | 'Windows Vista' | 'Windows 7' | 'Windows 8' | 'Windows 10' | 'Generic Windows'
      state: true | false
  },
  linux_os: {
      name:  'Debian' | 'Knoppix' | 'Mint' | 'Ubuntu' | 'Kubuntu' | 'Xubuntu' | 'Lubuntu' | 'Fedora' | 'Red hat' | 'Mandriva' | 'Gentoo' | 'Sabayon' | 'Slackware' | 'Suse' | 'CentOS' | 'Backtrack' | 'Generic Linux',
      state: true | false
  },
  bot: true | false
}

NEXT STEPS

  • Unit test and e2e.
  • Create a documentation page.
  • Work in demo page
  • Directive css classes:
<h1 *responsive-css="{
  bootstrap: {xl: 'micssclassxl', lg: 'micssclasslg'},
  orientation:{landscape: 'micssclasslandscape'}
}"></h1>
  • animations show/hide in directives

Contributors

  • Manu Cutillas
  • Christophe HOARAU
  • Kamil Breguła
  • Janne Julkunen
  • phransyz
  • Michael Burger
  • Alyssa Brunswick
  • Quentin
  • Thomas Christensen
  • lydemann
  • MattSenter

License

MIT license

ngx-responsive's People

Contributors

bjornharvold avatar ghetolay avatar louispennachio avatar lydemann avatar manucutillas avatar mik-laj avatar paulyipkh avatar phransyz avatar sconix avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ngx-responsive's Issues

Orientation not working correctly

The value of orientation is not working correctly.

I always get 'portrait' on my iPad (in both orientations - even after refreshing the page)

I always get 'landscape' on my laptop no matter how much i change the width of the browser window. (and refresh my page)

Also can anyone please tell me how to detect the change in Orientation?

HOWTO: Set an Angular variable depending on the viewport size

So Imagine this scenario

I have a main header navigation... that for:

md+ ..... always shown
xs, sm + hidden by default (but could be toggled with burger menu)

so, I use isNavShown variable to toggle the menu.... which should:
on window resize to md+ become true
on window resize to md- become false

so how would I tackle this logic from a directive? How do I interact with the isNavShown var

TypeScript definition file missing for responsive.js?

Hi, I'm using an Angular 2 starter project which is identical to the quickstarter app on Angular 2's website (https://angular.io/docs/ts/latest/quickstart.html) to test out ng2-responsive. I think it's pretty close to your demo app structure. After I follow your instructions to install and try to run the app when including some responsive directives, I get the following on "npm start". I got the same errors in your demo project even after I commented out the lines pertaining to responsive-directives-angular2 in systemjs.config.js.

Workaround for me at the moment is that to get the server running using "npm start" while ng2-responsive code is commented out. Once the server is running, if I comment the code back in, everything works fine.

I get almost identical errors if I remove the TS definition file for another ng2-responsive JS file, thus I think the following errors may be simply because of a missing TS definition file.

---------------------------------------Output of "npm start"-------------------------------------------
[email protected] start C:\angular2\responsiveTest
tsc && concurrently "npm run tsc:w" "npm run lite"

node_modules/responsive-directives-angular2/index.d.ts(6,28): error TS2307: Cannot find module './responsive/responsive'.
node_modules/responsive-directives-angular2/index.d.ts(14,15): error TS2307: Cannot find module './responsive/responsive'.

npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\tools\nodejs\node_modules\npm\bin\npm-cli.js" "start"
npm ERR! node v6.2.0
npm ERR! npm v3.9.3
npm ERR! code ELIFECYCLE
npm ERR! [email protected] start: tsc && concurrently "npm run tsc:w" "npm run lite"
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the [email protected] start script 'tsc && concurrently "npm run tsc:w" "npm run lite" '.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the angular2-quickstart package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! tsc && concurrently "npm run tsc:w" "npm run lite"
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs angular2-quickstart
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls angular2-quickstart
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! C:\angular2\responsiveTest\npm-debug.log

Custom size and breakpoints

Hello,

First of all, thanks a lot.

It would be great if it was possible to customize the service a little bit by changing the breakpoints size, and even better (but more complexe) by adding new breakpoints.

Thanks a lot.

Universal server side rendering

Just curious if you have had any thought on using this with universal server side rendering, what would be the best configuration?

Do you think just removing the global directive from the server bootstrap is the best option?

use ng2-responsive to set variable

Hi, can I use ng2-responsive to set variable for a component based on the size of the screen.
I am using the material design 2 sideNav and I want to change the mode depending on the screen size.
In material design 1 they where using $mdMedia like this...
<md-sidenav md-component-id="right" md-is-locked-open="$mdMedia('min-width: 333px')" class="md-sidenav-right">

Thanks!

Responsive Directive with css classes like ngClass

I'm working on a new directive like ngClass with responsive features.

<h1 [responsive-css]  xl="micssclassxl" lg="micssclasslg" ></h1>

OR

<h1 *responsive-css="{
         bootstrap: {xl: "micssclassxl", lg:"micssclasslg"},
         orientation:{landscape:"micssclasslandscape"}
        }"></h1>

Getting Error after Angular 2 RC6 update

Hi - There seems to be some incompatibility with Angular 2 RC6 and NG2-Repsonsive package.

Here is the error that i am getting:
index.js:67Uncaught TypeError: core_1.provide is not a function

Its probably because of some of the deprecations such as this one:
Instead of PLATFORM_PIPES and PLATFORM_DIRECTIVES, provide platform directives/pipes via an @NgModule.

Lots of Warnings in RC5

Hi - I am getting lots of warnings such as the ones attached below.

I am using Angular 2 RC5 using Node 4.5.0 and NPM 3.10.6

I installed the library using:
sudo npm i ng2-responsive --save

As soon as i use the library in my AppModule i start getting warning.

...
import { ResponsiveModule } from 'ng2-responsive';
...
@NgModule({
  declarations: [ AppComponent ],
  imports: [
    BrowserModule,
    CommonModule,
    FormsModule,
    routing,
    ResponsiveModule
  ],
  bootstrap: [AppComponent]
})
export class AppModule {}

These are some of the warnings:

WARNING in ./~/ng2-responsive/index.js
Cannot find SourceMap 'index.js.map': Error: Can't resolve './index.js.map' in '/project/node_modules/ng2-responsive'
 @ ./src/app/app.module.ts 18:0-50
 @ ./src/app/index.ts
 @ ./src/main.ts
 @ multi main

WARNING in ./~/ng2-responsive/config/config.js
Cannot find SourceMap 'config.js.map': Error: Can't resolve './config.js.map' in '/project/node_modules/ng2-responsive/config'
 @ ./~/ng2-responsive/index.js 34:15-41 43:15-41
 @ ./src/app/app.module.ts
 @ ./src/app/index.ts
 @ ./src/main.ts
 @ multi main

WARNING in ./~/ng2-responsive/bootstrap/bootstrap-directives.js
Cannot find SourceMap 'bootstrap-directives.js.map': Error: Can't resolve './bootstrap-directives.js.map' in '/project/node_modules/ng2-responsive/bootstrap'
 @ ./~/ng2-responsive/index.js 35:29-72
 @ ./src/app/app.module.ts
 @ ./src/app/index.ts
 @ ./src/main.ts
 @ multi main

WARNING in ./~/ng2-responsive/devices/devices-directives.js
Cannot find SourceMap 'devices-directives.js.map': Error: Can't resolve './devices-directives.js.map' in '/project/node_modules/ng2-responsive/devices'
 @ ./~/ng2-responsive/index.js 36:27-66
 @ ./src/app/app.module.ts
 @ ./src/app/index.ts
 @ ./src/main.ts
 @ multi main

WARNING in ./~/ng2-responsive/custom-sizes/custom-sizes-directives.js
Cannot find SourceMap 'custom-sizes-directives.js.map': Error: Can't resolve './custom-sizes-directives.js.map' in '/project/node_modules/ng2-responsive/custom-sizes'
 @ ./~/ng2-responsive/index.js 37:32-81
 @ ./src/app/app.module.ts
 @ ./src/app/index.ts
 @ ./src/main.ts
 @ multi main
...

P.S: I am using Angular-cli @ webpack

How can I run 'demo'?

Hi.
I like your idea behind this project 👍
But, I can't see demo.
I already installed nodejs packages (npm install)
What should I do which remained to do?

I get this error in console log:
GET http://test.local/responsive-directives-angular2.js 404 (Not Found) Error: Error: XHR error (404 Not Found) loading http://test.local/responsive-directives-angular2.js(…)
The file is requested not generated there!

Add one more breakpoint

Hi,

If you don't mind I would like to add an additional breakpoing (xl:1600).

Are you ok with this ?

ng2-responive installed in node_modules folder but app can not find ng2-responsive sub modules

I installed ng2-responsive in application's node-modules folder as instructed and made changes to the app.module.ts file. as shown below. I am running with Angular 2, version 2.1.1. When I start the app, it gives the following errors:

Errors

node_modules/ng2-responsive/index.d.ts(1,90): error TS2307: Cannot find module './bootstrap/bootstrap-directives'.
node_modules/ng2-responsive/index.d.ts(2,240): error TS2307: Cannot find module './devices/devices-directives'.
node_modules/ng2-responsive/index.d.ts(3,42): error TS2307: Cannot find module './custom-sizes/custom-sizes-directives'.
node_modules/ng2-responsive/index.d.ts(4,59): error TS2307: Cannot find module './pixelratio/pixelratio-directives'.
node_modules/ng2-responsive/index.d.ts(5,161): error TS2307: Cannot find module './browsers/browsers-directives'.
node_modules/ng2-responsive/index.d.ts(6,28): error TS2307: Cannot find module './responsive/responsive'.
node_modules/ng2-responsive/index.d.ts(7,34): error TS2307: Cannot find module './responsive-window/responsive-window'.
node_modules/ng2-responsive/index.d.ts(8,31): error TS2307: Cannot find module './useragent/useragent'.
node_modules/ng2-responsive/index.d.ts(9,43): error TS2307: Cannot find module './config/interfaces'.
node_modules/ng2-responsive/index.d.ts(10,51): error TS2307: Cannot find module './config/config'.

app.module.ts

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { FormsModule } from '@angular/forms';
import { AppRoutingModule } from './routes/app-routing.module';
import { CommonModule } from '@angular/common';
import {ResponsiveModule, ResponsiveConfig, ResponsiveConfigInterface} from 'ng2-responsive';

import {KnowledgeObjList} from './components/knowledgeObjList/knowledgeObjList.component';
import {MessageList} from './components/messages/messageList.component';
import {ContactList} from './components/contacts/contactList.component';
import {NewContact} from './components/contacts/newContact.component';
import {ContactInfo} from './components/contacts/contactInfo.component';
import {DocDisplay} from './components/docDisplay/docDisplay.component';
import {SearchBox} from './components/searchBox/searchBox.component';

import {ContactService} from './services/contact.service';
import {KnowledgeObjService} from './services/knowledgeObj.service';

import {SearchPipe} from './pipes/search.pipe';

let config: ResponsiveConfigInterface = {
breakPoints: {
xs: {max: 600},
sm: {min: 601, max: 959},
md: {min: 960, max: 1279},
lg: {min: 1280, max: 1919},
xl: {min: 1920}
},
debounceTime: 100 // allow to debounce checking timer
};

@NgModule({
imports: [ BrowserModule
, FormsModule
, AppRoutingModule
, ResponsiveModule
],
declarations: [ AppComponent
, KnowledgeObjList
, MessageList
, ContactList
, NewContact
, ContactInfo
, DocDisplay
, SearchBox
, SearchPipe ],
providers:[
{provide: ResponsiveConfig, useFactory: () => new ResponsiveConfig(config) }
],
bootstrap: [ AppComponent ]
})

export class AppModule { }

Implement ngOnDestroy and ngOnInit on directives

In order to improve code we should implements OnInit and OnDestroy on each classes.
I propose showItBootstrap as example for implementing other directives.
Do you think it's a good implementation ?

Template reference variables lost

Template reference variables are lost when a responsive directive is added. For example:
<input #phone placeholder="phone number" *xs>
In this case, referencing the 'phone' variable in other parts of the template yields an exception.

Small typo in src/config/responsive-base.ts

case "pixelratio": this.set_active_subscriptions.pixelratio == true; break;
should be only
this.set_active_subscriptions.pixelratio = true;
Also really nice work keep it up.
Would be nice if you could support angular2-universal, i know it's a bit complicated.
I`ve adapted the code for me to support it but it would break for people who don't use universal since i used the isBrowser constant from angular2-universal

Error when installing with angular-cli

angular: ~2.0.0
angular-cli: 1.0.0-beta.17
ng2-responsive: ^0.5.0

// app.module.ts

import { CommonModule } from '@angular/common';
import { ResponsiveModule } from 'ng2-responsive';

...

@NgModule({
    declarations: [
      AppComponent,
      ...
    ],
    imports: [
      ...
+     CommonModule,
+     ResponsiveModule
    ],
    ...
// output from 'ng serve'

ERROR in ./~/ng2-responsive/index.js
Module not found: Error: Can't resolve './devices/devices-directives' in '/Users/foo/Projects/bar/node_modules/ng2-responsive'
 @ ./~/ng2-responsive/index.js 36:27-66
 @ ./src/app/app.module.ts
 @ ./src/app/index.ts
 @ ./src/main.ts
 @ multi main

ERROR in [default] /Users/foo/Projects/bar/node_modules/ng2-responsive/index.d.ts:1:89
Cannot find module './bootstrap/bootstrap-directives'.

ERROR in [default] /Users/foo/Projects/bar/node_modules/ng2-responsive/index.d.ts:2:239
Cannot find module './devices/devices-directives'.

ERROR in [default] /Users/foo/Projects/bar/node_modules/ng2-responsive/index.d.ts:3:41
Cannot find module './custom-sizes/custom-sizes-directives'.

ERROR in [default] /Users/foo/Projects/bar/node_modules/ng2-responsive/index.d.ts:4:58
Cannot find module './pixelratio/pixelratio-directives'.

ERROR in [default] /Users/foo/Projects/bar/node_modules/ng2-responsive/index.d.ts:5:160
Cannot find module './browsers/browsers-directives'.

ERROR in [default] /Users/foo/Projects/bar/node_modules/ng2-responsive/index.d.ts:6:27
Cannot find module './responsive/responsive'.

ERROR in [default] /Users/foo/Projects/bar/node_modules/ng2-responsive/index.d.ts:7:33
Cannot find module './responsive-window/responsive-window'.

ERROR in [default] /Users/foo/Projects/bar/node_modules/ng2-responsive/index.d.ts:8:30
Cannot find module './useragent/useragent'.

ERROR in [default] /Users/foo/Projects/bar/node_modules/ng2-responsive/index.d.ts:9:42
Cannot find module './config/interfaces'.

ERROR in [default] /Users/foo/Projects/bar/node_modules/ng2-responsive/index.d.ts:10:50
Cannot find module './config/config'.

grid breakpoints do not match bootstrap and documentation

yours:

            breakPoints: {
                xs: { max: 767 },
                sm: { min: 768, max: 991 },
                md: { min: 992, max: 1199 },
                lg: { min: 1200, max: 1599 },
                xl: { min: 1600 }
            }

bootstrap 4:

// Grid breakpoints
//
// Define the minimum dimensions at which your layout will change,
// adapting to different screen sizes, for use in media queries.

$grid-breakpoints: (
  xs: 0,
  sm: 544px,
  md: 768px,
  lg: 992px,
  xl: 1200px
) !default;
@include _assert-ascending($grid-breakpoints, "$grid-breakpoints");

bootstrap 3:

// Grid breakpoints
//
// Define the minimum dimensions at which your layout will change,
// adapting to different screen sizes, for use in media queries.

$grid-breakpoints: (
  xs: 0,
  sm: 544px,
  md: 768px,
  lg: 992px,
  xl: 1200px
) !default;
@include _assert-ascending($grid-breakpoints, "$grid-breakpoints");

gap in sizeOperations

Hi,

There's a small issue in the sizeOperations function, you have strict comparison for both upper and lower values which results in 1px gap between size. You should change one of the comparison for example :
RESPONSIVE_DEVICE_SIZES.md.max > this.width should be RESPONSIVE_DEVICE_SIZES.md.max >= this.width

Thanks for the other updates

I´m working in fix this error in rollup library. : )

'ResponsiveConfig' is not exported by node_modules/ng2-responsive/index.js (imported by public/compiled-aot/src/app/app.module.js). For help fixing this error see https://github.com/rollup/rollup/wiki/Troubleshooting#name-is-not-exported-by-module

Error: 'ResponsiveConfig' is not exported by node_modules/ng2-responsive/index.js (imported by public/compiled-aot/src/app/app.module.js). For help fixing this error see https://github.com/rollup/rollup/wiki/Troubleshooting#name-is-not-exported-by-module
at Module.trace (/Users/apple/Desktop/Repositorios Git/ng2-responsive-aot/ng2-responsive/demo/node_modules/rollup/src/Module.js:362:30)
at ModuleScope.findDeclaration (/Users/apple/Desktop/Repositorios Git/ng2-responsive-aot/ng2-responsive/demo/node_modules/rollup/src/ast/scopes/ModuleScope.js:47:22)
at Scope.findDeclaration (/Users/apple/Desktop/Repositorios Git/ng2-responsive-aot/ng2-responsive/demo/node_modules/rollup/src/ast/scopes/Scope.js:92:39)
at Identifier.bind (/Users/apple/Desktop/Repositorios Git/ng2-responsive-aot/ng2-responsive/demo/node_modules/rollup/src/ast/nodes/Identifier.js:7:29)
at /Users/apple/Desktop/Repositorios Git/ng2-responsive-aot/ng2-responsive/demo/node_modules/rollup/src/ast/Node.js:6:34
at NewExpression.eachChild (/Users/apple/Desktop/Repositorios Git/ng2-responsive-aot/ng2-responsive/demo/node_modules/rollup/src/ast/Node.js:21:5)
at NewExpression.bind (/Users/apple/Desktop/Repositorios Git/ng2-responsive-aot/ng2-responsive/demo/node_modules/rollup/src/ast/Node.js:6:8)
at /Users/apple/Desktop/Repositorios Git/ng2-responsive-aot/ng2-responsive/demo/node_modules/rollup/src/ast/Node.js:6:34
at ReturnStatement.eachChild (/Users/apple/Desktop/Repositorios Git/ng2-responsive-aot/ng2-responsive/demo/node_modules/rollup/src/ast/Node.js:21:5)
at ReturnStatement.bind (/Users/apple/Desktop/Repositorios Git/ng2-responsive-aot/ng2-responsive/demo/node_modules/rollup/src/ast/Node.js:6:8)

Error: 'ResponsiveModule' is not exported by node_modules/ng2-responsive/index.js

I would really like to use the ResponsiveModule in my Angular2 project but I can't get it to run.

If I run the project on my local server it will not pass the 'Loading' message without any helping error messages in the console.
But when I run my release script I see this:
Export 'ResponsiveConfig' is not defined by '/Users/Bart/Documents/www/pegasus-ceRegistrar/bin-debug/aot/src/application/ApplicationModule.ngfactory.js'
Export 'ResponsiveConfigInterface' is not defined by '/Users/Bart/Documents/www/pegasus-ceRegistrar/bin-debug/aot/src/application/ApplicationModule.ngfactory.js'
Export 'ResponsiveState' is not defined by '/Users/Bart/Documents/www/pegasus-ceRegistrar/bin-debug/aot/src/application/ApplicationModule.ngfactory.js'
Export 'ResponsiveModule' is not defined by '/Users/Bart/Documents/www/pegasus-ceRegistrar/bin-debug/aot/src/application/ApplicationModule.ngfactory.js'
Export 'ResponsiveModule' is not defined by '/Users/Bart/Documents/www/pegasus-ceRegistrar/bin-debug/aot/src/application/ApplicationModule.ngfactory.js'
Export 'ResponsiveConfig' is not defined by '/Users/Bart/Documents/www/pegasus-ceRegistrar/bin-debug/aot/src/application/ApplicationModule.ngfactory.js'
Export 'ResponsiveState' is not defined by '/Users/Bart/Documents/www/pegasus-ceRegistrar/bin-debug/aot/src/application/ApplicationModule.ngfactory.js'
'ResponsiveModule' is not exported by node_modules/ng2-responsive/index.js (imported by bin-debug/src/application/ApplicationModule.js). For help fixing this error see https://github.com/rollup/rollup/wiki/Troubleshooting#name-is-not-exported-by-module
Error: 'ResponsiveModule' is not exported by node_modules/ng2-responsive/index.js (imported by bin-debug/src/application/ApplicationModule.js). For help fixing this error see https://github.com/rollup/rollup/wiki/Troubleshooting#name-is-not-exported-by-module

I've tried the solutions mentioned in issue #32 'projekt/ng2-responsive 404 error' but it's not working :-(

Could you please tell me what I'm doing wrong?

Below you can see my project config files.

package.json
{
"name": "pegasus-ceRegistrar",
"version": "0.0.1",
"dependencies": {
"@angular/common": "^2.4.1",
"@angular/compiler": "^2.4.1",
"@angular/compiler-cli": "^2.4.1",
"@angular/core": "^2.4.1",
"@angular/forms": "^2.4.1",
"@angular/http": "^2.4.1",
"@angular/material": "^2.0.0-beta.1",
"@angular/platform-browser": "^2.4.1",
"@angular/platform-browser-dynamic": "^2.4.1",
"@angular/platform-server": "^2.4.1",
"@angular/router": "^3.4.1",
"@angular/upgrade": "^2.4.1",
"@types/core-js": "^0.9",
"@types/hammerjs": "^2.0.34",
"@types/node": "^6.0.54",
"angular-in-memory-web-api": "^0.1",
"angular2-jwt": "^0.1.25",
"concurrently": "^3.0.0",
"core-js": "^2",
"grunt": "^1",
"grunt-contrib-clean": "^1",
"grunt-contrib-copy": "^1",
"grunt-shell": "^2",
"hammerjs": "^2.0.8",
"lite-server": "^2",
"load-grunt-tasks": "^3",
"ng2-responsive": "^0.6.6",
"reflect-metadata": "^0.1.9",
"rollup": "^0.36",
"rollup-plugin-commonjs": "^5",
"rollup-plugin-node-resolve": "^2",
"rollup-plugin-uglify": "^1",
"rxjs": "^5.0.2",
"systemjs": "^0.19",
"tslint": "^4.2.0",
"typescript": "2.0.10",
"zone.js": "^0.7.4"
}
}

systemjs.config.js
(function (global) {
System.config({
paths: {
'npm:': 'node_modules/'
},
map: {
Application: 'bin-debug',

  // angular bundles
  '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
  '@angular/common': 'npm:@angular/common/bundles/common.umd.js',
  '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
  '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
  '@angular/http': 'npm:@angular/http/bundles/http.umd.js',
  '@angular/material': 'npm:@angular/material/bundles/material.umd.js',
  '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
  '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
  '@angular/router': 'npm:@angular/router/bundles/router.umd.js',
  '@angular/upgrade': 'npm:@angular/upgrade/bundles/upgrade.umd.js',

  // response libraries
  'ng2-responsive/bootstrap': 'npm:ng2-responsive/bootstrap',
  'ng2-responsive/browsers': 'npm:ng2-responsive/browsers',
  'ng2-responsive/config': 'npm:ng2-responsive/config',
  'ng2-responsive/custom-sizes': 'npm:ng2-responsive/custom-sizes',
  'ng2-responsive/devices': 'npm:ng2-responsive/devices',
  'ng2-responsive/pixelratio': 'npm:ng2-responsive/pixelratio',
  'ng2-responsive/responsive': 'npm:ng2-responsive/responsive',
  'ng2-responsive/responsive-window': 'npm:ng2-responsive/responsive-window',
  'ng2-responsive/useragent': 'npm:ng2-responsive/useragent',
  'ng2-responsive': 'npm:ng2-responsive',

  // other libraries
  'rxjs': 'npm:rxjs'
},
packages: {
  Application: {
    main: './main.js',
    defaultExtension: 'js'
  },
  'ng2-responsive/bootstrap': {
    main: './index.js',
    defaultExtension: 'js'
  },
  'ng2-responsive/browsers': {
    main: './index.js',
    defaultExtension: 'js'
  },
  'ng2-responsive/config': {
    main: './index.js',
    defaultExtension: 'js'
  },
  'ng2-responsive/custom-sizes': {
    main: './index.js',
    defaultExtension: 'js'
  },
  'ng2-responsive/devices': {
    main: './index.js',
    defaultExtension: 'js'
  },
  'ng2-responsive/pixelratio': {
    main: './index.js',
    defaultExtension: 'js'
  },
  'ng2-responsive/responsive': {
    main: './index.js',
    defaultExtension: 'js'
  },
  'ng2-responsive/responsive-window': {
    main: './index.js',
    defaultExtension: 'js'
  },
  'ng2-responsive/useragent': {
    main: './index.js',
    defaultExtension: 'js'
  },
  'ng2-responsive': {
    main: './index.js',
    defaultExtension: 'js'
  },
  rxjs: {
    defaultExtension: 'js'
  }
}

});
})(this);

Unexpected value 'ResponsiveModule' imported by the module 'AppModule'

I'm trying to AOT (Ahead-of-Time) compile an application that uses ng2-responsive. from what I can gather, it seems as if ng2-responsive is only JIT (Just-in-Time) ready. Demo only shows the use of platformBrowserDynamic.

Am I missing something or is this already on the horizon? Any plan release to support this?

Directive for using element size instead of the screen size for responsivenes

Our application can be standalone (full page app) or embedded (i.e. fills certain div of the page) so we need to make the application responsive to the "parent" div size not the screen size for it to work in all situations.

So far this library seems like the best way to make our app responsive and the only feature missing is to be able to define a div which size is used instead of the screen size. My current thought is that there could be *responsive-window directive set to true/false (active or not) to define the component which size is used instead of the screen size.

I have just started using angular2 a week a go so I decided to ask if this kind of feature would make sense before fully jumping into implementing it. I already made a quick test to define the "responsive window/root/screen" via DOM selector and to fetch the element size via querySelector and it works nicely, but currently I think the directive approach would be more efficient and perhaps the best way to implement this feature.

So do you think this kind of feature would make sense and is the suggested approach best way to go in your opinion?

Proposition: create ng switch like directive

Hi,

I don't know yet how, but it would be great to have an ngSwitch like feature.

I can see at least 2 ways to do it:

  • use defaut ngSwitch, and expose size with another directive (in order to avoid injecting the service everywhere).
    • This have the drawback of using 2 directives but the advantage of being very simple code and easy to maintain.
  • create an ngSwitchResponsive (or other name), and ngSwitchResponsiveWhen='breakpoints name array or string'.
    • This seems more clean way to do it, but require a lot more work. I haven't checked but ngSwitch defaut directive might be quite complex.
    • The advantage of this solution is we could match several breakpoints on a single switchWhen like with showItBootstrap

What do you think about it ?

Add directives to common angular directives in version rc5

I wrote code below to use this plugin in my angular application after updating to rc5. but directives won't insert to angular common directives .

app.module.ts

import { NgModule, enableProdMode, provide, PLATFORM_DIRECTIVES } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';

import { ResponsiveState, RESPONSIVE_DIRECTIVES } from 'responsive-directives-angular2';

import { AppComponent } from './app.component';
import { SharedService } from "./services/shared.service";

@NgModule({
    imports: [BrowserModule, HttpModule],
    declarations: [AppComponent],
    providers: [SharedService, ResponsiveState, provide(PLATFORM_DIRECTIVES, { useValue: [RESPONSIVE_DIRECTIVES], multi: true })],
    bootstrap: [AppComponent]
})
export class AppModule { }

As angular website described, in rc5 module concept added and there is ability to create modules and imports them to main app just like HttpModule or BrowserModule.
So maybe you can convert your plugin to a module and make the usage process easier.

Suggestion: Create dynamic classes

Hi,

I think in some cases it would be great to be able to show/hide only with css classes. This could be useful when we need to show hide lots of small elements as it will reduce the number of bindings in the page.

We could use a directive to enable the feature, which would great css classes based on breakpoints defined in the service and insert them in the dom.

Please tell me if you agree to include this before I start working on it.

You've done a great job with all new features and refactoring !!! Amazing.

Thanks.

sub files not found

I know this has been reported before, and it was fixed, but for some reason I get the following console errors:

zone.js:1382 GET http://localhost:3000/node_modules/ng2-responsive/bootstrap.js 404 (Not Found)scheduleTask @ zone.js:1382ZoneDelegate.scheduleTask @ zone.js:245Zone.scheduleMacroTask @ zone.js:171(anonymous function) @ zone.js:1405send @ VM52561:3fetchTextFromURL @ system.src.js:1051(anonymous function) @ system.src.js:1781ZoneAwarePromise @ zone.js:518(anonymous function) @ system.src.js:1780(anonymous function) @ system.src.js:2809(anonymous function) @ system.src.js:3387(anonymous function) @ system.src.js:3701(anonymous function) @ system.src.js:4093(anonymous function) @ system.src.js:4556(anonymous function) @ system.src.js:4825(anonymous function) @ system.src.js:407ZoneDelegate.invoke @ zone.js:232Zone.run @ zone.js:114(anonymous function) @ zone.js:502ZoneDelegate.invokeTask @ zone.js:265Zone.runTask @ zone.js:154drainMicroTaskQueue @ zone.js:401ZoneTask.invoke @ zone.js:339
klantenservice:43 Error: (SystemJS) XHR error (404 Not Found) loading http://localhost:3000/node_modules/ng2-responsive/bootstrap.js(…)(anonymous function) @ klantenservice:43ZoneDelegate.invoke @ zone.js:232Zone.run @ zone.js:114(anonymous function) @ zone.js:502ZoneDelegate.invokeTask @ zone.js:265Zone.runTask @ zone.js:154drainMicroTaskQueue @ zone.js:401ZoneTask.invoke @ zone.js:339
zone.js:1382 GET http://localhost:3000/node_modules/ng2-responsive/browsers.js 404 (Not Found)scheduleTask @ zone.js:1382ZoneDelegate.scheduleTask @ zone.js:245Zone.scheduleMacroTask @ zone.js:171(anonymous function) @ zone.js:1405send @ VM52561:3fetchTextFromURL @ system.src.js:1051(anonymous function) @ system.src.js:1781ZoneAwarePromise @ zone.js:518(anonymous function) @ system.src.js:1780(anonymous function) @ system.src.js:2809(anonymous function) @ system.src.js:3387(anonymous function) @ system.src.js:3701(anonymous function) @ system.src.js:4093(anonymous function) @ system.src.js:4556(anonymous function) @ system.src.js:4825(anonymous function) @ system.src.js:407ZoneDelegate.invoke @ zone.js:232Zone.run @ zone.js:114(anonymous function) @ zone.js:502ZoneDelegate.invokeTask @ zone.js:265Zone.runTask @ zone.js:154drainMicroTaskQueue @ zone.js:401ZoneTask.invoke @ zone.js:339
zone.js:1382 GET http://localhost:3000/node_modules/ng2-responsive/custom-sizes.js 404 (Not Found)scheduleTask @ zone.js:1382ZoneDelegate.scheduleTask @ zone.js:245Zone.scheduleMacroTask @ zone.js:171(anonymous function) @ zone.js:1405send @ VM52561:3fetchTextFromURL @ system.src.js:1051(anonymous function) @ system.src.js:1781ZoneAwarePromise @ zone.js:518(anonymous function) @ system.src.js:1780(anonymous function) @ system.src.js:2809(anonymous function) @ system.src.js:3387(anonymous function) @ system.src.js:3701(anonymous function) @ system.src.js:4093(anonymous function) @ system.src.js:4556(anonymous function) @ system.src.js:4825(anonymous function) @ system.src.js:407ZoneDelegate.invoke @ zone.js:232Zone.run @ zone.js:114(anonymous function) @ zone.js:502ZoneDelegate.invokeTask @ zone.js:265Zone.runTask @ zone.js:154drainMicroTaskQueue @ zone.js:401ZoneTask.invoke @ zone.js:339
zone.js:1382 GET http://localhost:3000/node_modules/ng2-responsive/devices.js 404 (Not Found)scheduleTask @ zone.js:1382ZoneDelegate.scheduleTask @ zone.js:245Zone.scheduleMacroTask @ zone.js:171(anonymous function) @ zone.js:1405send @ VM52561:3fetchTextFromURL @ system.src.js:1051(anonymous function) @ system.src.js:1781ZoneAwarePromise @ zone.js:518(anonymous function) @ system.src.js:1780(anonymous function) @ system.src.js:2809(anonymous function) @ system.src.js:3387(anonymous function) @ system.src.js:3701(anonymous function) @ system.src.js:4093(anonymous function) @ system.src.js:4556(anonymous function) @ system.src.js:4825(anonymous function) @ system.src.js:407ZoneDelegate.invoke @ zone.js:232Zone.run @ zone.js:114(anonymous function) @ zone.js:502ZoneDelegate.invokeTask @ zone.js:265Zone.runTask @ zone.js:154drainMicroTaskQueue @ zone.js:401ZoneTask.invoke @ zone.js:339
zone.js:1382 GET http://localhost:3000/node_modules/ng2-responsive/pixelratio.js 404 (Not Found)scheduleTask @ zone.js:1382ZoneDelegate.scheduleTask @ zone.js:245Zone.scheduleMacroTask @ zone.js:171(anonymous function) @ zone.js:1405send @ VM52561:3fetchTextFromURL @ system.src.js:1051(anonymous function) @ system.src.js:1781ZoneAwarePromise @ zone.js:518(anonymous function) @ system.src.js:1780(anonymous function) @ system.src.js:2809(anonymous function) @ system.src.js:3387(anonymous function) @ system.src.js:3701(anonymous function) @ system.src.js:4093(anonymous function) @ system.src.js:4556(anonymous function) @ system.src.js:4825(anonymous function) @ system.src.js:407ZoneDelegate.invoke @ zone.js:232Zone.run @ zone.js:114(anonymous function) @ zone.js:502ZoneDelegate.invokeTask @ zone.js:265Zone.runTask @ zone.js:154drainMicroTaskQueue @ zone.js:401ZoneTask.invoke @ zone.js:339
zone.js:1382 GET http://localhost:3000/node_modules/ng2-responsive/responsive.js 404 (Not Found)scheduleTask @ zone.js:1382ZoneDelegate.scheduleTask @ zone.js:245Zone.scheduleMacroTask @ zone.js:171(anonymous function) @ zone.js:1405send @ VM52561:3fetchTextFromURL @ system.src.js:1051(anonymous function) @ system.src.js:1781ZoneAwarePromise @ zone.js:518(anonymous function) @ system.src.js:1780(anonymous function) @ system.src.js:2809(anonymous function) @ system.src.js:3387(anonymous function) @ system.src.js:3701(anonymous function) @ system.src.js:4093(anonymous function) @ system.src.js:4556(anonymous function) @ system.src.js:4825(anonymous function) @ system.src.js:407ZoneDelegate.invoke @ zone.js:232Zone.run @ zone.js:114(anonymous function) @ zone.js:502ZoneDelegate.invokeTask @ zone.js:265Zone.runTask @ zone.js:154drainMicroTaskQueue @ zone.js:401ZoneTask.invoke @ zone.js:339
zone.js:1382 GET http://localhost:3000/node_modules/ng2-responsive/responsive-window.js 404 (Not Found)scheduleTask @ zone.js:1382ZoneDelegate.scheduleTask @ zone.js:245Zone.scheduleMacroTask @ zone.js:171(anonymous function) @ zone.js:1405send @ VM52561:3fetchTextFromURL @ system.src.js:1051(anonymous function) @ system.src.js:1781ZoneAwarePromise @ zone.js:518(anonymous function) @ system.src.js:1780(anonymous function) @ system.src.js:2809(anonymous function) @ system.src.js:3387(anonymous function) @ system.src.js:3701(anonymous function) @ system.src.js:4093(anonymous function) @ system.src.js:4556(anonymous function) @ system.src.js:4825(anonymous function) @ system.src.js:407ZoneDelegate.invoke @ zone.js:232Zone.run @ zone.js:114(anonymous function) @ zone.js:502ZoneDelegate.invokeTask @ zone.js:265Zone.runTask @ zone.js:154drainMicroTaskQueue @ zone.js:401ZoneTask.invoke @ zone.js:339
zone.js:1382 GET http://localhost:3000/node_modules/ng2-responsive/useragent.js 404 (Not Found)

Looks like it is looking for file which should be in a sub-folder but it's looking for them in the root folder of the plugin.

Is it something I did wrong?

projekt/ng2-responsive 404 error

Your install guide didn't work in the first place with ng2-Final, typescript 2.0.2 for the Angular Get Started App.

I resolved the issue with adding
'responsive': 'npm:ng2-responsive',
and
'ng2-responsive': { main: './index.js', defaultExtension: 'js' }
to system.config.js.

app.module.ts

import {NgModule} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';

import {MdCoreModule} from '@angular2-material/core';
import {MdSidenavModule} from '@angular2-material/sidenav';

import {Ng2BootstrapModule} from "ng2-bootstrap/ng2-bootstrap";

import {AppComponent} from "./app.component";
import {ResponsiveModule} from "ng2-responsive";

@NgModule({
    imports:      [
        BrowserModule,
        ResponsiveModule,
        Ng2BootstrapModule,
        MdCoreModule,
        MdSidenavModule
    ],
    declarations: [
        AppComponent
    ],
    bootstrap:    [
        AppComponent
    ]
})

export class AppModule { }

system.config.js

(function (global) {
    System.config({
        paths: {
            // paths serve as alias
            'npm:': 'node_modules/'
        },
        // map tells the System loader where to look for things
        map: {
            // our app is within the app folder
            app: 'app',
            // angular bundles
            '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
            '@angular/common': 'npm:@angular/common/bundles/common.umd.js',
            '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
            '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
            '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
            '@angular/http': 'npm:@angular/http/bundles/http.umd.js',
            '@angular/router': 'npm:@angular/router/bundles/router.umd.js',
            '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',

            '@angular2-material/core': 'npm:@angular2-material/core/core.umd.js',
            '@angular2-material/sidenav': 'npm:@angular2-material/sidenav/sidenav.umd.js',
            // other libraries
            'rxjs':                       'npm:rxjs',
            'angular2-in-memory-web-api': 'npm:angular2-in-memory-web-api',

            'ng2-responsive': 'npm:ng2-responsive',

            'moment': 'node_modules/moment/moment.js'
        },
        // packages tells the System loader how to load when no filename and/or no extension
        packages: {
            app: {
                main: './main.js',
                defaultExtension: 'js'
            },
            rxjs: {
                defaultExtension: 'js'
            },
            'angular2-in-memory-web-api': {
                main: './index.js',
                defaultExtension: 'js'
            },
            'ng2-responsive': {
                main: './index.js',
                defaultExtension: 'js'
            }
        }
    });
})(this);

Add support for greater-than or lower-than

Hello,

First of all, thanks a lot.

It would be great if it was possible to add a few directives to show/hide elements which when screen is greater (or less) than a breakpoint. In angular material 1 there used to be directives like :hide-gt-sm or :show-lt-lg, it was very usefull.

Thanks a lot.

responsive-css.ts is empty

Hi,

I have just upgraded to the last version (from the previous reprository) and responsive-css.ts is empty. Is the feature removed or replaced with something else ?

Thanks and great job !!

Add BrowserInfo and DeviceStandardInfo directive to Module.

It would be a good idea to give access to BrowserInfo and DeviceStandardInfo directives. Should be a super quick win. Changes are marked with bold.

ng2-responsive\index.d.ts
2: import { ... , DeviceStandardInfo } from './devices/devices-directives';
5: import { ... , BrowserInfo } from './browsers/browsers-directives';
11: export declare const RESPONSIVE_DIRECTIVES: ( ... | typeof BrowserInfo | typeof DeviceStandardInfo)[];

Question: How to add browser name as a 'class' to the body tag

Hi - Can someone please tell me how to add the client browser as a class to the body tag.

For example, if i am using Chrome:
<body class="chrome">

Or if i am using Firefox:
<body class="firefox">

This makes it quite easy to write browser specific hacks in CSS :)

Conflict with primeng

I'm getting a No provider for TemplateRef! error when using datatable from primeng as soon as I include ResponsiveModule in my project even if I don't use any directives from it. Any idea what could cause the problem?

I'm using angular2 2.0.3, primeng beta 17 and ng2-responsive 0.4.6

Error: XHR error (404 Not Found) loading http://localhost:8000/ng2-responsive

Hi I'm receiving this error:
Error: XHR error (404 Not Found) loading http://localhost:8000/ng2-responsive

AppModule (path:"project"/App/AppModule):
...
import { ResponsiveModule, ResponsiveConfig, ResponsiveConfigInterface } from 'ng2-responsive';
...
@NgModule({
imports: [
BrowserModule,
FormsModule,
routing,
HttpModule,
ResponsiveModule,
InMemoryWebApiModule.forRoot(InMemoryDataService, { delay: 600 })
],
...
providers: [
ItemService,
{provide: ResponsiveConfig, useFactory: () => new ResponsiveConfig(config) }
],
bootstrap: [BodyComponent]
})

Cannot find module './bootstrap/bootstrap-directives'.

When trying to use webkit I'm getting the error Cannot find module './bootstrap/bootstrap-directives'.

When I look in node_modules/ng2-bootstrap/index.d.ts I see lots of red squiggles because there aren't any typescript files, only .js files

Debounce change detection

I have added a debounce time to change detection (100ms by default)

If you don't want it I can set it to 0 by default which will result in the actual behavior.

Service which exposes size state

Hey, would like to be able to use ng2-responsive in my TypeScript code as well. Is there any service that exposes this right now?

For instance, would like to be able to do:

if( this.responsive.isLg() ) {
   // ...
}

Suggestion: add classes at breakpoints

In many cases I don't want to create multiple elements for large/small layouts, I simply need a different css class applied. It would be nice to have a directive that would apply a css class based on the screen size (versus show/hiding the element).
For example:

<p *sm-class="my-small-class" *lg-class="my-big-class">example</p>

When the window is small, .my-small-class is applied to the element, and when the screen is large, .my-big-class would be applied to the element.

Can't find ResponsiveConfigInterface

I had to explicitly dig into the folder structure to find it since the index.d.ts in the config folder doesn't explicitly export the interface.

import { ResponsiveModule, ResponsiveConfig } from "ng2-responsive";
import { ResponsiveConfigInterface } from "ng2-responsive/config/config";

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.