Demo: https://andre-lehnert.github.io/ng-devices/
Requires peer dependency: Angular ~7.2.0
ng build ng-devices
cd dist/ng-devices
npm pack
Include archive to your project:
package.json
"dependencies": {
"ng-devices": "file:<path to your archive>/ng-devices-0.0.1.tgz"
}
TODO
Import library:
app.module.ts
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
NgDeviceModule
],
providers: [
],
bootstrap: [AppComponent]
})
export class AppModule {}
Angular Component and HTML:
app.component.ts
...
import {Device} from 'ng-devices';
...
@Component({
selector: 'app-root',
template: `
<ng-device [device]="selectedDevice" [landscape]="false">
<!-- Your content -->
<h1>Hello World</h1>
</ng-device>
`
})
export class AppComponent implements OnInit {
public selectedDevice: Device = Device.APPLE_MACBOOK_PRO;
...
}
Minimal HTML:
<ng-device></ng-device>
Demo: https://andre-lehnert.github.io/ng-devices/assets/web-component/
npm run package
to generate the angular-devices.js file in the root folder
http-server -o
to provide the index.html in the root folder
Optional npm run package:gzip
to reduce the file size from 240 KB to 60 KB.
The http server have to support content-encoding: gzip
response headers.